The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
thmlrtf.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  *
3  * thmlrtf.cpp - ThML to RTF filter
4  *
5  * $Id: thmlrtf.cpp 3547 2017-12-10 05:06:48Z scribe $
6  *
7  * Copyright 1999-2013 CrossWire Bible Society (http://www.crosswire.org)
8  * CrossWire Bible Society
9  * P. O. Box 2528
10  * Tempe, AZ 85280-2528
11  *
12  * This program is free software; you can redistribute it and/or modify it
13  * under the terms of the GNU General Public License as published by the
14  * Free Software Foundation version 2.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * General Public License for more details.
20  *
21  */
22 
23 #include <stdlib.h>
24 #include <thmlrtf.h>
25 #include <swmodule.h>
26 #include <utilxml.h>
27 #include <utilstr.h>
28 #include <versekey.h>
29 
31 
33  setTokenStart("<");
34  setTokenEnd(">");
35 
36  setEscapeStart("&");
37  setEscapeEnd(";");
38 
40 
41  addEscapeStringSubstitute("nbsp", "\302\240");
42  addEscapeStringSubstitute("apos", "'");
43  addEscapeStringSubstitute("quot", "\"");
44  addEscapeStringSubstitute("amp", "&");
45  addEscapeStringSubstitute("lt", "<");
46  addEscapeStringSubstitute("gt", ">");
47  addEscapeStringSubstitute("brvbar", "¦); addEscapeStringSubstitute("sect", "§"); addEscapeStringSubstitute("copy", "©"); addEscapeStringSubstitute("laquo", "«"); addEscapeStringSubstitute("reg", "®"); addEscapeStringSubstitute("acute", "´"); addEscapeStringSubstitute("para", "¶"); addEscapeStringSubstitute("raquo", "»"); addEscapeStringSubstitute("Aacute", "Á"); addEscapeStringSubstitute("Agrave", "À"); addEscapeStringSubstitute("Acirc", "Â"); addEscapeStringSubstitute("Auml", "Ä"); addEscapeStringSubstitute("Atilde", "Ã"); addEscapeStringSubstitute("Aring", "Å"); addEscapeStringSubstitute("aacute", "á"); addEscapeStringSubstitute("agrave", "à"); addEscapeStringSubstitute("acirc", "â"); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
48  addEscapeStringSubstitute("sect", "§); addEscapeStringSubstitute("copy", "©"); addEscapeStringSubstitute("laquo", "«"); addEscapeStringSubstitute("reg", "®"); addEscapeStringSubstitute("acute", "´"); addEscapeStringSubstitute("para", "¶"); addEscapeStringSubstitute("raquo", "»"); addEscapeStringSubstitute("Aacute", "Á"); addEscapeStringSubstitute("Agrave", "À"); addEscapeStringSubstitute("Acirc", "Â"); addEscapeStringSubstitute("Auml", "Ä"); addEscapeStringSubstitute("Atilde", "Ã"); addEscapeStringSubstitute("Aring", "Å"); addEscapeStringSubstitute("aacute", "á"); addEscapeStringSubstitute("agrave", "à"); addEscapeStringSubstitute("acirc", "â"); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
49  addEscapeStringSubstitute("copy", "©); addEscapeStringSubstitute("laquo", "«"); addEscapeStringSubstitute("reg", "®"); addEscapeStringSubstitute("acute", "´"); addEscapeStringSubstitute("para", "¶"); addEscapeStringSubstitute("raquo", "»"); addEscapeStringSubstitute("Aacute", "Á"); addEscapeStringSubstitute("Agrave", "À"); addEscapeStringSubstitute("Acirc", "Â"); addEscapeStringSubstitute("Auml", "Ä"); addEscapeStringSubstitute("Atilde", "Ã"); addEscapeStringSubstitute("Aring", "Å"); addEscapeStringSubstitute("aacute", "á"); addEscapeStringSubstitute("agrave", "à"); addEscapeStringSubstitute("acirc", "â"); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
50  addEscapeStringSubstitute("laquo", "«); addEscapeStringSubstitute("reg", "®"); addEscapeStringSubstitute("acute", "´"); addEscapeStringSubstitute("para", "¶"); addEscapeStringSubstitute("raquo", "»"); addEscapeStringSubstitute("Aacute", "Á"); addEscapeStringSubstitute("Agrave", "À"); addEscapeStringSubstitute("Acirc", "Â"); addEscapeStringSubstitute("Auml", "Ä"); addEscapeStringSubstitute("Atilde", "Ã"); addEscapeStringSubstitute("Aring", "Å"); addEscapeStringSubstitute("aacute", "á"); addEscapeStringSubstitute("agrave", "à"); addEscapeStringSubstitute("acirc", "â"); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
51  addEscapeStringSubstitute("reg", "®); addEscapeStringSubstitute("acute", "´"); addEscapeStringSubstitute("para", "¶"); addEscapeStringSubstitute("raquo", "»"); addEscapeStringSubstitute("Aacute", "Á"); addEscapeStringSubstitute("Agrave", "À"); addEscapeStringSubstitute("Acirc", "Â"); addEscapeStringSubstitute("Auml", "Ä"); addEscapeStringSubstitute("Atilde", "Ã"); addEscapeStringSubstitute("Aring", "Å"); addEscapeStringSubstitute("aacute", "á"); addEscapeStringSubstitute("agrave", "à"); addEscapeStringSubstitute("acirc", "â"); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
52  addEscapeStringSubstitute("acute", "´); addEscapeStringSubstitute("para", "¶"); addEscapeStringSubstitute("raquo", "»"); addEscapeStringSubstitute("Aacute", "Á"); addEscapeStringSubstitute("Agrave", "À"); addEscapeStringSubstitute("Acirc", "Â"); addEscapeStringSubstitute("Auml", "Ä"); addEscapeStringSubstitute("Atilde", "Ã"); addEscapeStringSubstitute("Aring", "Å"); addEscapeStringSubstitute("aacute", "á"); addEscapeStringSubstitute("agrave", "à"); addEscapeStringSubstitute("acirc", "â"); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
53  addEscapeStringSubstitute("para", "¶); addEscapeStringSubstitute("raquo", "»"); addEscapeStringSubstitute("Aacute", "Á"); addEscapeStringSubstitute("Agrave", "À"); addEscapeStringSubstitute("Acirc", "Â"); addEscapeStringSubstitute("Auml", "Ä"); addEscapeStringSubstitute("Atilde", "Ã"); addEscapeStringSubstitute("Aring", "Å"); addEscapeStringSubstitute("aacute", "á"); addEscapeStringSubstitute("agrave", "à"); addEscapeStringSubstitute("acirc", "â"); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
54  addEscapeStringSubstitute("raquo", "»); addEscapeStringSubstitute("Aacute", "Á"); addEscapeStringSubstitute("Agrave", "À"); addEscapeStringSubstitute("Acirc", "Â"); addEscapeStringSubstitute("Auml", "Ä"); addEscapeStringSubstitute("Atilde", "Ã"); addEscapeStringSubstitute("Aring", "Å"); addEscapeStringSubstitute("aacute", "á"); addEscapeStringSubstitute("agrave", "à"); addEscapeStringSubstitute("acirc", "â"); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
55 
56  addEscapeStringSubstitute("Aacute", "Á); addEscapeStringSubstitute("Agrave", "À"); addEscapeStringSubstitute("Acirc", "Â"); addEscapeStringSubstitute("Auml", "Ä"); addEscapeStringSubstitute("Atilde", "Ã"); addEscapeStringSubstitute("Aring", "Å"); addEscapeStringSubstitute("aacute", "á"); addEscapeStringSubstitute("agrave", "à"); addEscapeStringSubstitute("acirc", "â"); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
57  addEscapeStringSubstitute("Agrave", "À); addEscapeStringSubstitute("Acirc", "Â"); addEscapeStringSubstitute("Auml", "Ä"); addEscapeStringSubstitute("Atilde", "Ã"); addEscapeStringSubstitute("Aring", "Å"); addEscapeStringSubstitute("aacute", "á"); addEscapeStringSubstitute("agrave", "à"); addEscapeStringSubstitute("acirc", "â"); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
58  addEscapeStringSubstitute("Acirc", "Â); addEscapeStringSubstitute("Auml", "Ä"); addEscapeStringSubstitute("Atilde", "Ã"); addEscapeStringSubstitute("Aring", "Å"); addEscapeStringSubstitute("aacute", "á"); addEscapeStringSubstitute("agrave", "à"); addEscapeStringSubstitute("acirc", "â"); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
59  addEscapeStringSubstitute("Auml", "Ä); addEscapeStringSubstitute("Atilde", "Ã"); addEscapeStringSubstitute("Aring", "Å"); addEscapeStringSubstitute("aacute", "á"); addEscapeStringSubstitute("agrave", "à"); addEscapeStringSubstitute("acirc", "â"); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
60  addEscapeStringSubstitute("Atilde", "Ã); addEscapeStringSubstitute("Aring", "Å"); addEscapeStringSubstitute("aacute", "á"); addEscapeStringSubstitute("agrave", "à"); addEscapeStringSubstitute("acirc", "â"); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
61  addEscapeStringSubstitute("Aring", "Å); addEscapeStringSubstitute("aacute", "á"); addEscapeStringSubstitute("agrave", "à"); addEscapeStringSubstitute("acirc", "â"); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
62  addEscapeStringSubstitute("aacute", "á); addEscapeStringSubstitute("agrave", "à"); addEscapeStringSubstitute("acirc", "â"); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
63  addEscapeStringSubstitute("agrave", "à); addEscapeStringSubstitute("acirc", "â"); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
64  addEscapeStringSubstitute("acirc", "â); addEscapeStringSubstitute("auml", "ä"); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
65  addEscapeStringSubstitute("auml", "ä); addEscapeStringSubstitute("atilde", "ã"); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
66  addEscapeStringSubstitute("atilde", "ã); addEscapeStringSubstitute("aring", "å"); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
67  addEscapeStringSubstitute("aring", "å); addEscapeStringSubstitute("Eacute", "É"); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
68  addEscapeStringSubstitute("Eacute", "É); addEscapeStringSubstitute("Egrave", "È"); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
69  addEscapeStringSubstitute("Egrave", "È); addEscapeStringSubstitute("Ecirc", "Ê"); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
70  addEscapeStringSubstitute("Ecirc", "Ê); addEscapeStringSubstitute("Euml", "Ë"); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
71  addEscapeStringSubstitute("Euml", "Ë); addEscapeStringSubstitute("eacute", "é"); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
72  addEscapeStringSubstitute("eacute", "é); addEscapeStringSubstitute("egrave", "è"); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
73  addEscapeStringSubstitute("egrave", "è); addEscapeStringSubstitute("ecirc", "ê"); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
74  addEscapeStringSubstitute("ecirc", "ê); addEscapeStringSubstitute("euml", "ë"); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
75  addEscapeStringSubstitute("euml", "ë); addEscapeStringSubstitute("Iacute", "Í"); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
76  addEscapeStringSubstitute("Iacute", "Í); addEscapeStringSubstitute("Igrave", "Ì"); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
77  addEscapeStringSubstitute("Igrave", "Ì); addEscapeStringSubstitute("Icirc", "Î"); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
78  addEscapeStringSubstitute("Icirc", "Î); addEscapeStringSubstitute("Iuml", "Ï"); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
79  addEscapeStringSubstitute("Iuml", "Ï); addEscapeStringSubstitute("iacute", "í"); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
80  addEscapeStringSubstitute("iacute", "í); addEscapeStringSubstitute("igrave", "ì"); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
81  addEscapeStringSubstitute("igrave", "ì); addEscapeStringSubstitute("icirc", "î"); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
82  addEscapeStringSubstitute("icirc", "î); addEscapeStringSubstitute("iuml", "ï"); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
83  addEscapeStringSubstitute("iuml", "ï); addEscapeStringSubstitute("Oacute", "Ó"); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
84  addEscapeStringSubstitute("Oacute", "Ó); addEscapeStringSubstitute("Ograve", "Ò"); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
85  addEscapeStringSubstitute("Ograve", "Ò); addEscapeStringSubstitute("Ocirc", "Ô"); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
86  addEscapeStringSubstitute("Ocirc", "Ô); addEscapeStringSubstitute("Ouml", "Ö"); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
87  addEscapeStringSubstitute("Ouml", "Ö); addEscapeStringSubstitute("Otilde", "Õ"); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
88  addEscapeStringSubstitute("Otilde", "Õ); addEscapeStringSubstitute("oacute", "ó"); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
89  addEscapeStringSubstitute("oacute", "ó); addEscapeStringSubstitute("ograve", "ò"); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
90  addEscapeStringSubstitute("ograve", "ò); addEscapeStringSubstitute("ocirc", "ô"); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
91  addEscapeStringSubstitute("ocirc", "ô); addEscapeStringSubstitute("ouml", "ö"); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
92  addEscapeStringSubstitute("ouml", "ö); addEscapeStringSubstitute("otilde", "õ"); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
93  addEscapeStringSubstitute("otilde", "õ); addEscapeStringSubstitute("Uacute", "Ú"); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
94  addEscapeStringSubstitute("Uacute", "Ú); addEscapeStringSubstitute("Ugrave", "Ù"); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
95  addEscapeStringSubstitute("Ugrave", "Ù); addEscapeStringSubstitute("Ucirc", "Û"); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
96  addEscapeStringSubstitute("Ucirc", "Û); addEscapeStringSubstitute("Uuml", "Ü"); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
97  addEscapeStringSubstitute("Uuml", "Ü); addEscapeStringSubstitute("uacute", "ú"); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
98  addEscapeStringSubstitute("uacute", "ú); addEscapeStringSubstitute("ugrave", "ù"); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
99  addEscapeStringSubstitute("ugrave", "ù); addEscapeStringSubstitute("ucirc", "û"); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
100  addEscapeStringSubstitute("ucirc", "û); addEscapeStringSubstitute("uuml", "ü"); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
101  addEscapeStringSubstitute("uuml", "ü); addEscapeStringSubstitute("Yacute", "Ý"); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
102  addEscapeStringSubstitute("Yacute", "Ý); addEscapeStringSubstitute("yacute", "ý"); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
103  addEscapeStringSubstitute("yacute", "ý); addEscapeStringSubstitute("yuml", "ÿ"); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
104  addEscapeStringSubstitute("yuml", "ÿ); addEscapeStringSubstitute("deg", "°"); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
105 
106  addEscapeStringSubstitute("deg", "°); addEscapeStringSubstitute("plusmn", "±"); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
107  addEscapeStringSubstitute("plusmn", "±); addEscapeStringSubstitute("sup2", "²"); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
108  addEscapeStringSubstitute("sup2", "²); addEscapeStringSubstitute("sup3", "³"); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
109  addEscapeStringSubstitute("sup3", "³); addEscapeStringSubstitute("sup1", "¹"); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
110  addEscapeStringSubstitute("sup1", "¹); addEscapeStringSubstitute("nbsp", "º"); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
111  addEscapeStringSubstitute("nbsp", "º); addEscapeStringSubstitute("pound", "£"); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
112  addEscapeStringSubstitute("pound", "£); addEscapeStringSubstitute("cent", "¢"); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
113  addEscapeStringSubstitute("cent", "¢); addEscapeStringSubstitute("frac14", "¼"); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
114  addEscapeStringSubstitute("frac14", "¼); addEscapeStringSubstitute("frac12", "½"); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
115  addEscapeStringSubstitute("frac12", "½); addEscapeStringSubstitute("frac34", "¾"); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
116  addEscapeStringSubstitute("frac34", "¾); addEscapeStringSubstitute("iquest", "¿"); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
117  addEscapeStringSubstitute("iquest", "¿); addEscapeStringSubstitute("iexcl", "¡"); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
118  addEscapeStringSubstitute("iexcl", "¡); addEscapeStringSubstitute("ETH", "Ð"); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
119  addEscapeStringSubstitute("ETH", "Ð); addEscapeStringSubstitute("eth", "ð"); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
120  addEscapeStringSubstitute("eth", "ð); addEscapeStringSubstitute("THORN", "Þ"); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
121  addEscapeStringSubstitute("THORN", "Þ); addEscapeStringSubstitute("thorn", "þ"); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
122  addEscapeStringSubstitute("thorn", "þ); addEscapeStringSubstitute("AElig", "Æ"); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
123  addEscapeStringSubstitute("AElig", "Æ); addEscapeStringSubstitute("aelig", "æ"); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
124  addEscapeStringSubstitute("aelig", "æ); addEscapeStringSubstitute("Oslash", "Ø"); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
125  addEscapeStringSubstitute("Oslash", "Ø); addEscapeStringSubstitute("curren", "¤"); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
126  addEscapeStringSubstitute("curren", "¤); addEscapeStringSubstitute("Ccedil", "Ç"); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
127  addEscapeStringSubstitute("Ccedil", "Ç); addEscapeStringSubstitute("ccedil", "ç"); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
128  addEscapeStringSubstitute("ccedil", "ç); addEscapeStringSubstitute("szlig", "ß"); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
129  addEscapeStringSubstitute("szlig", "ß); addEscapeStringSubstitute("Ntilde", "Ñ"); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
130  addEscapeStringSubstitute("Ntilde", "Ñ); addEscapeStringSubstitute("ntilde", "ñ"); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
131  addEscapeStringSubstitute("ntilde", "ñ); addEscapeStringSubstitute("yen", "¥"); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
132  addEscapeStringSubstitute("yen", "¥); addEscapeStringSubstitute("not", "¬"); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
133  addEscapeStringSubstitute("not", "¬); addEscapeStringSubstitute("ordf", "ª"); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
134  addEscapeStringSubstitute("ordf", "ª); addEscapeStringSubstitute("uml", "¨"); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
135  addEscapeStringSubstitute("uml", "¨); addEscapeStringSubstitute("shy", "­"); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
136  addEscapeStringSubstitute("shy", "­); addEscapeStringSubstitute("macr", "¯"); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
137  addEscapeStringSubstitute("macr", "¯); addEscapeStringSubstitute("micro", "µ"); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
138 
139  addEscapeStringSubstitute("micro", "µ); addEscapeStringSubstitute("middot", "·"); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
140  addEscapeStringSubstitute("middot", "·); addEscapeStringSubstitute("cedil", "¸"); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
141  addEscapeStringSubstitute("cedil", "¸); addEscapeStringSubstitute("ordm", "º"); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
142  addEscapeStringSubstitute("ordm", "º); addEscapeStringSubstitute("times", "×"); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
143  addEscapeStringSubstitute("times", "×); addEscapeStringSubstitute("divide", "÷"); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
144  addEscapeStringSubstitute("divide", "÷); addEscapeStringSubstitute("oslash", "ø"); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
145  addEscapeStringSubstitute("oslash", "ø); setTokenCaseSensitive(true); addTokenSubstitute("br", "\\line "); addTokenSubstitute("br /", "\\line "); addTokenSubstitute("i", "{\\i1 "); addTokenSubstitute("/i", "}"); addTokenSubstitute("b", "{\\b1 "); addTokenSubstitute("/b", "}"); addTokenSubstitute("p", "{\\fi200\\par}"); addTokenSubstitute("p /", "\\pard\\par\\par "); //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant addTokenSubstitute("BR", "\\line "); addTokenSubstitute("I", "{\\i1 "); addTokenSubstitute("/I", "}"); addTokenSubstitute("B", "{\\b1 "); addTokenSubstitute("/B", "}"); addTokenSubstitute("P", "\\par "); addTokenSubstitute("scripture", "{\\i1 "); addTokenSubstitute("/scripture", "}"); addTokenSubstitute("center", "\\qc "); addTokenSubstitute("/center", "\\pard "); } char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) { // preprocess text buffer to escape RTF control codes const char *from; SWBuf orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces switch (*from) { case '{': case '}': case '\\': text += "\\"; text += *from; break; default: text += *from; } } text += (char)0; SWBasicFilter::processText(text, key, module); //handle tokens as usual orig = text; from = orig.c_str(); for (text = ""; *from; from++) { //loop to remove extra spaces if ((strchr(" \t\n\r", *from))) { while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) { from++; } text += " "; } else { text += *from; } } text += (char)0; // probably not needed, but don't want to remove without investigating (same as above) return 0; } ThMLRTF::MyUserData::MyUserData(const SWModule *module, const SWKey *key) : BasicFilterUserData(module, key) { isBiblicalText = false; inSecHead = false; XMLTag startTag = ""; if (module) { version = module->getName(); isBiblicalText = (!strcmp(module->getType(), "Biblical Texts")); } } bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) { if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution MyUserData *u = (MyUserData *)userData; XMLTag tag(token); if ((!tag.isEndTag()) && (!tag.isEmpty())) u->startTag = tag; if (tag.getName() && !strcmp(tag.getName(), "sync")) { SWBuf value = tag.getAttribute("value"); if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) { if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') { value<<1; buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str()); } else if (value[0] == 'T') { value<<1; buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str()); } } else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) { if (!tag.isEndTag()) buf += "{\\b "; else buf += "}"; } } // <note> tag else if (!strcmp(tag.getName(), "note")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { SWBuf type = tag.getAttribute("type"); SWBuf footnoteNumber = tag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'); buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str()); } u->suspendTextPassThru = true; } } if (tag.isEndTag()) { u->suspendTextPassThru = false; } } else if (!strcmp(tag.getName(), "scripRef")) { if (!tag.isEndTag()) { if (!tag.isEmpty()) { u->suspendTextPassThru = true; } } if (tag.isEndTag()) { // </scripRef> if (!u->isBiblicalText) { SWBuf refList = u->startTag.getAttribute("passage"); if (!refList.length()) refList = u->lastTextNode; SWBuf version = tag.getAttribute("version"); buf += "<a href=\"\">"; buf += refList.c_str(); // buf += u->lastTextNode.c_str(); buf += "</a>"; } else { SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote"); if (u->vkey) { // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt. buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str()); } } // let's let text resume to output again u->suspendTextPassThru = false; } } else if (tag.getName() && !strcmp(tag.getName(), "div")) { if (tag.isEndTag() && u->inSecHead) { buf += "\\par}"; u->inSecHead = false; } else if (tag.getAttribute("class")) { if (!stricmp(tag.getAttribute("class"), "sechead")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } else if (!stricmp(tag.getAttribute("class"), "title")) { u->inSecHead = true; buf += "{\\par\\i1\\b1 "; } } } else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) { const char *src = tag.getAttribute("src"); if (!src) // assert we have a src attribute return false; char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)]; *filepath = 0; strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath")); strcat(filepath, src); // we do this because BibleCS looks for this EXACT format for an image tag buf+="<img src=\""; buf+=filepath; buf+="\" />"; delete [] filepath; } else { return false; // we still didn't handle token } } return true; } SWORD_NAMESPACE_END ");
146 
147  setTokenCaseSensitive(true);
148 
149 
150  addTokenSubstitute("br", "\\line ");
151  addTokenSubstitute("br /", "\\line ");
152  addTokenSubstitute("i", "{\\i1 ");
153  addTokenSubstitute("/i", "}");
154  addTokenSubstitute("b", "{\\b1 ");
155  addTokenSubstitute("/b", "}");
156  addTokenSubstitute("p", "{\\fi200\\par}");
157  addTokenSubstitute("p /", "\\pard\\par\\par ");
158 
159  //we need uppercase forms for the moment to support a few early ThML modules that aren't XHTML compliant
160  addTokenSubstitute("BR", "\\line ");
161  addTokenSubstitute("I", "{\\i1 ");
162  addTokenSubstitute("/I", "}");
163  addTokenSubstitute("B", "{\\b1 ");
164  addTokenSubstitute("/B", "}");
165  addTokenSubstitute("P", "\\par ");
166  addTokenSubstitute("scripture", "{\\i1 ");
167  addTokenSubstitute("/scripture", "}");
168  addTokenSubstitute("center", "\\qc ");
169  addTokenSubstitute("/center", "\\pard ");
170 }
171 
172 
173 char ThMLRTF::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
174 
175  // preprocess text buffer to escape RTF control codes
176  const char *from;
177  SWBuf orig = text;
178  from = orig.c_str();
179  for (text = ""; *from; from++) { //loop to remove extra spaces
180  switch (*from) {
181  case '{':
182  case '}':
183  case '\\':
184  text += "\\";
185  text += *from;
186  break;
187  default:
188  text += *from;
189  }
190  }
191  text += (char)0;
192 
193  SWBasicFilter::processText(text, key, module); //handle tokens as usual
194 
195  orig = text;
196  from = orig.c_str();
197  for (text = ""; *from; from++) { //loop to remove extra spaces
198  if ((strchr(" \t\n\r", *from))) {
199  while (*(from+1) && (strchr(" \t\n\r", *(from+1)))) {
200  from++;
201  }
202  text += " ";
203  }
204  else {
205  text += *from;
206  }
207  }
208  text += (char)0; // probably not needed, but don't want to remove without investigating (same as above)
209  return 0;
210 }
211 
212 
214  isBiblicalText = false;
215  inSecHead = false;
216  XMLTag startTag = "";
217  if (module) {
218  version = module->getName();
219  isBiblicalText = (!strcmp(module->getType(), "Biblical Texts"));
220  }
221 }
222 
223 
224 bool ThMLRTF::handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData) {
225  if (!substituteToken(buf, token)) { // manually process if it wasn't a simple substitution
226  MyUserData *u = (MyUserData *)userData;
227  XMLTag tag(token);
228  if ((!tag.isEndTag()) && (!tag.isEmpty()))
229  u->startTag = tag;
230  if (tag.getName() && !strcmp(tag.getName(), "sync")) {
231  SWBuf value = tag.getAttribute("value");
232  if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "morph")) { //&gt;
233  buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str());
234  }
235  else if( tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Strongs")) {
236  if (value[0] == 'H' || value[0] == 'G' || value[0] == 'A') {
237  value<<1;
238  buf.appendFormatted(" {\\cf3 \\sub <%s>}", value.c_str());
239  }
240  else if (value[0] == 'T') {
241  value<<1;
242  buf.appendFormatted(" {\\cf4 \\sub (%s)}", value.c_str());
243  }
244  }
245  else if (tag.getAttribute("type") && !strcmp(tag.getAttribute("type"), "Dict")) {
246  if (!tag.isEndTag())
247  buf += "{\\b ";
248  else buf += "}";
249  }
250  }
251  // <note> tag
252  else if (!strcmp(tag.getName(), "note")) {
253  if (!tag.isEndTag()) {
254  if (!tag.isEmpty()) {
255  SWBuf type = tag.getAttribute("type");
256  SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
257  if (u->vkey) {
258  // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
259  char ch = ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n');
260  buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ch, u->vkey->getVerse(), footnoteNumber.c_str());
261  }
262  u->suspendTextPassThru = true;
263  }
264  }
265  if (tag.isEndTag()) {
266  u->suspendTextPassThru = false;
267  }
268  }
269 
270 
271  else if (!strcmp(tag.getName(), "scripRef")) {
272  if (!tag.isEndTag()) {
273  if (!tag.isEmpty()) {
274  u->suspendTextPassThru = true;
275  }
276  }
277  if (tag.isEndTag()) { // </scripRef>
278  if (!u->isBiblicalText) {
279  SWBuf refList = u->startTag.getAttribute("passage");
280  if (!refList.length())
281  refList = u->lastTextNode;
282  SWBuf version = tag.getAttribute("version");
283  buf += "<a href=\"\">";
284  buf += refList.c_str();
285 // buf += u->lastTextNode.c_str();
286  buf += "</a>";
287  }
288  else {
289  SWBuf footnoteNumber = u->startTag.getAttribute("swordFootnote");
290  if (u->vkey) {
291  // leave this special osis type in for crossReference notes types? Might thml use this some day? Doesn't hurt.
292  buf.appendFormatted("{\\super <a href=\"\">*x%i.%s</a>} ", u->vkey->getVerse(), footnoteNumber.c_str());
293  }
294  }
295 
296  // let's let text resume to output again
297  u->suspendTextPassThru = false;
298  }
299  }
300 
301  else if (tag.getName() && !strcmp(tag.getName(), "div")) {
302  if (tag.isEndTag() && u->inSecHead) {
303  buf += "\\par}";
304  u->inSecHead = false;
305  }
306  else if (tag.getAttribute("class")) {
307  if (!stricmp(tag.getAttribute("class"), "sechead")) {
308  u->inSecHead = true;
309  buf += "{\\par\\i1\\b1 ";
310  }
311  else if (!stricmp(tag.getAttribute("class"), "title")) {
312  u->inSecHead = true;
313  buf += "{\\par\\i1\\b1 ";
314  }
315  }
316  }
317  else if (tag.getName() && (!strcmp(tag.getName(), "img") || !strcmp(tag.getName(), "image"))) {
318  const char *src = tag.getAttribute("src");
319  if (!src) // assert we have a src attribute
320  return false;
321 
322  char* filepath = new char[strlen(u->module->getConfigEntry("AbsoluteDataPath")) + strlen(token)];
323  *filepath = 0;
324  strcpy(filepath, userData->module->getConfigEntry("AbsoluteDataPath"));
325  strcat(filepath, src);
326 
327 // we do this because BibleCS looks for this EXACT format for an image tag
328  buf+="<img src=\"";
329  buf+=filepath;
330  buf+="\" />";
331  delete [] filepath;
332  }
333  else {
334  return false; // we still didn't handle token
335  }
336  }
337  return true;
338 }
339 
340 
const char * getName() const
Definition: swmodule.cpp:204
MyUserData(const SWModule *module, const SWKey *key)
Definition: thmlrtf.cpp:213
#define SWORD_NAMESPACE_START
Definition: defs.h:39
SWBuf & appendFormatted(const char *format,...)
Definition: swbuf.cpp:81
virtual char processText(SWBuf &text, const SWKey *key=0, const SWModule *module=0)
Definition: thmlrtf.cpp:173
void setTokenEnd(const char *tokenEnd)
Definition: swbuf.h:47
unsigned long length() const
Definition: swbuf.h:197
virtual char processText(SWBuf &text, const SWKey *key=0, const SWModule *module=0)
const char * getType() const
Definition: swmodule.cpp:232
virtual const char * getConfigEntry(const char *key) const
Definition: swmodule.cpp:1159
const SWModule * module
Definition: swbasicfilter.h:42
const char * getName() const
Definition: utilxml.h:58
SWText * module
Definition: osis2mod.cpp:105
Definition: utilxml.h:38
void setTokenCaseSensitive(bool val)
void setEscapeStart(const char *escStart)
bool isEmpty() const
Definition: utilxml.h:60
bool substituteToken(SWBuf &buf, const char *token)
int stricmp(const char *s1, const char *s2)
Definition: utilstr.cpp:194
const VerseKey * vkey
Definition: swbasicfilter.h:44
void addEscapeStringSubstitute(const char *findString, const char *replaceString)
void setTokenStart(const char *tokenStart)
const char * c_str() const
Definition: swbuf.h:158
virtual bool handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData)
Definition: thmlrtf.cpp:224
virtual int getVerse() const
Definition: versekey.cpp:1534
ThMLRTF()
Definition: thmlrtf.cpp:32
const char * getAttribute(const char *attribName, int partNum=-1, char partSplit= '|') const
Definition: utilxml.cpp:230
void setEscapeStringCaseSensitive(bool val)
bool isEndTag(const char *eID=0) const
Definition: utilxml.cpp:323
void addTokenSubstitute(const char *findString, const char *replaceString)
void setEscapeEnd(const char *escEnd)
#define SWORD_NAMESPACE_END
Definition: defs.h:40
Definition: swkey.h:77