[sword-cvs] sword/src/modules/filters osisfootnotes.cpp,1.3,1.4 osisrtf.cpp,1.6,1.7

sword@www.crosswire.org sword@www.crosswire.org
Wed, 25 Jun 2003 21:33:33 -0700


Update of /usr/local/cvsroot/sword/src/modules/filters
In directory www:/tmp/cvs-serv9597/src/modules/filters

Modified Files:
	osisfootnotes.cpp osisrtf.cpp 
Log Message:
no message

Index: osisfootnotes.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osisfootnotes.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** osisfootnotes.cpp	18 Jun 2003 20:14:59 -0000	1.3
--- osisfootnotes.cpp	26 Jun 2003 04:33:31 -0000	1.4
***************
*** 69,78 ****
  			XMLTag tag(token);
  			if (!stricmp(tag.getName(), "note")) {
- 				if ((tag.getAttribute("type")) && (!stricmp(tag.getAttribute("type"), "strongsMarkup")) && (!tag.isEmpty())) {
- 					startTag = tag;
- 					hide = true;
- 					tagText = "";
- 					continue;
- 				}
  				if (!tag.isEndTag() && (!tag.isEmpty())) {
  					startTag = tag;
--- 69,72 ----
***************
*** 87,91 ****
  				}
  				if (hide && tag.isEndTag()) {
- 
  					if (module->isProcessEntryAttributes() && option) {
  						sprintf(buf, "%i", footnoteNum++);
--- 81,84 ----

Index: osisrtf.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osisrtf.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** osisrtf.cpp	25 Jun 2003 03:45:46 -0000	1.6
--- osisrtf.cpp	26 Jun 2003 04:33:31 -0000	1.7
***************
*** 44,194 ****
  bool OSISRTF::handleToken(SWBuf &buf, const char *token, DualStringMap &userData) {
    // manually process if it wasn't a simple substitution
!   if (!substituteToken(buf, token)) {
! 	XMLTag tag(token);
!     //w
!     if (!strncmp(token, "w", 1)) {
!       buf += "{";
!       userData["w"] = token;
!     }
!     else if (!strncmp(token, "/w", 2)) {
  
!       pos1 = userData["w"].find("xlit=\"", 0);
!       if (pos1 != string::npos) {
! 	pos1 = userData["w"].find(":", pos1) + 1;
! 	pos2 = userData["w"].find("\"", pos1) - 1;
! 	tagData = userData["w"].substr(pos1, pos2-pos1);
!         buf.appendFormatted(" {\\fs15 <%s>}", tagData.c_str() );
!       }
!       pos1 = userData["w"].find("gloss=\"", 0);
!       if (pos1 != string::npos) {
! 	pos1 = userData["w"].find(":", pos1) + 1;
! 	pos2 = userData["w"].find("\"", pos1) - 1;
! 	tagData = userData["w"].substr(pos1, pos2-pos1);
!         buf.appendFormatted(" {\\fs15 <%s>}", tagData.c_str() );
!       }
!       pos1 = userData["w"].find("lemma=\"", 0);
!       if (pos1 != string::npos) {
! 	pos1 = userData["w"].find(":", pos1) + 1;
! 	pos2 = userData["w"].find("\"", pos1) - 1;
! 	tagData = userData["w"].substr(pos1, pos2-pos1);
!         buf.appendFormatted(" {\\fs15 <%s>}", tagData.c_str() );
!       }
!       pos1 = userData["w"].find("morph=\"", 0);
!       if (pos1 != string::npos) {
! 	pos1 = userData["w"].find(":", pos1) + 1;
! 	pos2 = userData["w"].find("\"", pos1) - 1;
! 	tagData = userData["w"].substr(pos1, pos2-pos1);
!         buf.appendFormatted(" {\\fs15 <%s>}", tagData.c_str() );
!       }
!       pos1 = userData["w"].find("POS=\"", 0);
!       if (pos1 != string::npos) {
! 	pos1 = userData["w"].find(":", pos1) + 1;
! 	pos2 = userData["w"].find("\"", pos1) - 1;
! 	tagData = userData["w"].substr(pos1, pos2-pos1);
!         buf.appendFormatted(" {\\fs15 <%s>}", tagData.c_str() );
!       }
  
!       buf += "}";
!     }
! 	else if (!strcmp(tag.getName(), "note")) {
! 		if (!tag.isEmpty() && !tag.isEndTag()) {
! 			string footnoteNum = userData["fn"];
! 			int footnoteNumber = (footnoteNum.length()) ? atoi(footnoteNum.c_str()) : 1;
! 			VerseKey *vkey;
! 			// see if we have a VerseKey * or decendant
! 			try {
! 				vkey = SWDYNAMIC_CAST(VerseKey, this->key);
  			}
! 			catch ( ... ) {	}
! 			if (vkey) {
! 				buf.appendFormatted("{\\super <a href=\"\">*%c%i.%i</a>} ", ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'), vkey->Verse(), footnoteNumber);
! 				SWBuf tmp;
! 				tmp.appendFormatted("%i", ++footnoteNumber);
! 				userData["fn"] = tmp.c_str();
  			}
- 			userData["suspendTextPassThru"] = "true";
  		}
! 		if (tag.isEndTag()) {
! 			userData["suspendTextPassThru"] = "false";
  		}
- 	}
  
!     //p
!     else if (!strncmp(token, "p", 1)) {
!       buf += "{\\par ";
!     }
!     else if (!strncmp(token, "/p", 2)) {
!       buf += "\\par}";
!     }
  
!     //reference
!     else if (!strncmp(token, "reference", 8)) {
!       buf += "{<a href=\"\">";
!     }
!     else if (!strncmp(token, "/reference", 9)) {
!       buf += "</a>}";
!     }
  
!     //line
!     else if (!strncmp(token, "line", 4)) {
!       buf += "{";
!     }
!     else if (!strncmp(token, "/line", 5)) {
!       buf += "\\par}";
!     }
  
  
!     //title
!     else if (!strncmp(token, "title", 5)) {
!       buf += "{\\i1\\b1 ";
!     }
!     else if (!strncmp(token, "/title", 6)) {
!       buf += "\\par}";
!     }
  
!     //hi
!     else if (!strncmp(token, "hi", 2)) {
!       tagData=token;
!       pos1 = tagData.find("type=\"b", 0);
!       if (pos1 != string::npos) {
! 	buf += "{\\b1 ";
!       }
!       else {
! 	buf += "{\\i1 ";
!       }
!     }
!     else if (!strncmp(token, "/hi", 3)) {
!       buf += "}";
!     }
  
!     //q
!     else if (!strncmp(token, "q", 1)) {
!       buf += "{";
!       tagData=token;
!       pos1 = tagData.find("who=\"", 0);
!       if (pos1 != string::npos) {
! 	pos2 = tagData.find("\"", pos1);
! 	if (tagData.substr(pos1, pos2).find("Jesus", 0) != string::npos) {
! 	  buf += "\\cf6 ";
! 	}
!       }
!     }
!     else if (!strncmp(token, "/q", 2)) {
!       buf += "}";
!     }
  
!     //transChange
!     else if (!strncmp(token, "transChange", 11)) {
!       buf += "{\\i1 ";
!     }
!     else if (!strncmp(token, "/transChange", 12)) {
!       buf += "}";
!     }
  
!     else {
!       return false;  // we still didn't handle token
!     }
!   }
!   return true;
  }
  
--- 44,269 ----
  bool OSISRTF::handleToken(SWBuf &buf, const char *token, DualStringMap &userData) {
    // manually process if it wasn't a simple substitution
! 	if (!substituteToken(buf, token)) {
! 		XMLTag tag(token);
! 		
! 		// <w> tag
! 		if (!strcmp(tag.getName(), "w")) {
  
! 			// start <w> tag
! 			if ((!tag.isEmpty()) && (!tag.isEndTag())) {
! 				buf += "{";
! 				userData["w"] = token;
! 			}
  
! 			// end or empty <w> tag
! 			else {
! 				bool endTag = tag.isEndTag();
! 				SWBuf lastText;
! 				bool show = true;	// to handle unplaced article in kjv2003-- temporary till combined
! 
! 				if (endTag) {
! 					tag = userData["w"].c_str();
! 					lastText = userData["lastTextNode"].c_str();
! 				}
! 				else lastText = "stuff";
! 					
! 				const char *attrib;
! 				const char *val;
! 				if (attrib = tag.getAttribute("xlit")) {
! 					val = strchr(attrib, ':');
! 					val = (val) ? (val + 1) : attrib;
! 					buf.appendFormatted(" {\\fs15 <%s>}", val);
! 				}
! 				if (attrib = tag.getAttribute("gloss")) {
! 					val = strchr(attrib, ':');
! 					val = (val) ? (val + 1) : attrib;
! 					buf.appendFormatted(" {\\fs15 <%s>}", val);
! 				}
! 				if (attrib = tag.getAttribute("lemma")) {
! 					int count = tag.getAttributePartCount("lemma");
! 					int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
! 					do {
! 						attrib = tag.getAttribute("lemma", i);
! 						if (i < 0) i = 0;	// to handle our -1 condition
! 						val = strchr(attrib, ':');
! 						val = (val) ? (val + 1) : attrib;
! 						if ((strchr("GH", *val)) && (isdigit(val[1])))
! 							val++;
! 						if ((!strcmp(val, "3588")) && (lastText.length() < 1))
! 							show = false;
! 						else	buf.appendFormatted(" {\\cf3 \\sub <%s>}", val);
! 					} while (++i < count);
! 				}
! 				if ((attrib = tag.getAttribute("morph")) && (show)) {
! 					int count = tag.getAttributePartCount("morph");
! 					int i = (count > 1) ? 0 : -1;		// -1 for whole value cuz it's faster, but does the same thing as 0
! 					do {
! 						attrib = tag.getAttribute("morph", i);
! 						if (i < 0) i = 0;	// to handle our -1 condition
! 						val = strchr(attrib, ':');
! 						val = (val) ? (val + 1) : attrib;
! 						if ((*val == 'T') && (strchr("GH", val[1])) && (isdigit(val[2])))
! 							val+=2;
! 						buf.appendFormatted(" {\\cf4 \\sub (%s)}", val);
! 					} while (++i < count);
! 				}
! 				if (attrib = tag.getAttribute("POS")) {
! 					val = strchr(attrib, ':');
! 					val = (val) ? (val + 1) : attrib;
! 					buf.appendFormatted(" {\\fs15 <%s>}", val);
! 				}
! 
! 				if (endTag)
! 					buf += "}";
  			}
! 		}
! 
! 		// <note> tag
! 		else if (!strcmp(tag.getName(), "note")) {
! 			if (!tag.isEmpty() && !tag.isEndTag()) {
! 				string footnoteNum = userData["fn"];
! 				SWBuf type = tag.getAttribute("type");
! 
! 				if (type != "strongsMarkup") {	// leave strong's markup notes out, in the future we'll probably have different option filters to turn different note types on or off
! 					int footnoteNumber = (footnoteNum.length()) ? atoi(footnoteNum.c_str()) : 1;
! 					VerseKey *vkey;
! 					// see if we have a VerseKey * or decendant
! 					try {
! 						vkey = SWDYNAMIC_CAST(VerseKey, this->key);
! 					}
! 					catch ( ... ) {	}
! 					if (vkey) {
! 						buf.appendFormatted("{\\super <a href=\"\">*%c%i.%i</a>} ", ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'), vkey->Verse(), footnoteNumber);
! 						SWBuf tmp;
! 						tmp.appendFormatted("%i", ++footnoteNumber);
! 						userData["fn"] = tmp.c_str();
! 					}
! 				}
! 				userData["suspendTextPassThru"] = "true";
! 			}
! 			if (tag.isEndTag()) {
! 				userData["suspendTextPassThru"] = "false";
  			}
  		}
! 
! 		// <p> paragraph tag
! 		else if (!strcmp(tag.getName(), "p")) {
! 			if ((!tag.isEndTag()) && (!tag.isEmpty())) {	// non-empty start tag
! 				buf += "{\\par ";
! 			}
! 			else if (tag.isEndTag()) {	// end tag
! 				buf += "\\par}";
! 			}
! 			else {					// empty paragraph break marker
! 				buf += "{\\par\\par}";
! 			}
  		}
  
! 		// <reference> tag
! 		else if (!strcmp(tag.getName(), "reference")) {
! 			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
! 				buf += "{<a href=\"\">";
! 			}
! 			else if (tag.isEndTag()) {
! 				buf += "</a>}";
! 			}
! 			else {	// empty reference marker
! 				// -- what should we do?  nothing for now.
! 			}
! 		}
  
! 		// <line> poetry, etc
! 		else if (!strcmp(tag.getName(), "line")) {
! 			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
! 				buf += "{";
! 			}
! 			else if (tag.isEndTag()) {
! 				buf += "\\par}";
! 			}
! 			else {	// empty line marker
! 				buf += "{\\par}";
! 			}
! 		}
  
! 		// <title>
! 		else if (!strcmp(tag.getName(), "title")) {
! 			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
! 				buf += "{\\i1\\b1 ";
! 			}
! 			else if (tag.isEndTag()) {
! 				buf += "\\par}";
! 			}
! 			else {	// empty title marker
! 				// what to do?  is this even valid?
! 				buf += "{\\par}";
! 			}
! 		}
  
+ 		// <hi> hi?  hi contrast?
+ 		else if (!strcmp(tag.getName(), "hi")) {
+ 			SWBuf type = tag.getAttribute("type");
+ 			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
+ 				if (type == "b")
+ 					buf += "{\\b1 ";
+ 				else	// all other types
+ 					buf += "{\\i1 ";
+ 			}
+ 			else if (tag.isEndTag()) {
+ 				buf += "}";
+ 			}
+ 			else {	// empty hi marker
+ 				// what to do?  is this even valid?
+ 			}
+ 		}
  
! 		// <q> quote
! 		else if (!strcmp(tag.getName(), "q")) {
! 			SWBuf type = tag.getAttribute("type");
! 			SWBuf who = tag.getAttribute("who");
! 			const char *lev = tag.getAttribute("level");
! 			int level = (lev) ? atoi(lev) : 1;
! 			
! 			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
! 				buf += "{";
  
! 				//alternate " and '
! 				buf += (level % 2) ? '\'' : '\"';
! 				
! 				if (who == "Jesus")
! 					buf += "\\cf6 ";
! 			}
! 			else if (tag.isEndTag()) {
! 				//alternate " and '
! 				buf += (level % 2) ? '\'' : '\"';
! 				buf += "}";
! 			}
! 			else {	// empty quote marker
! 				//alternate " and '
! 				buf += (level % 2) ? '\'' : '\"';
! 			}
! 		}
  
! 		// <transChange>
! 		else if (!strcmp(tag.getName(), "transChange")) {
! 			SWBuf type = tag.getAttribute("type");
! 			
! 			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
  
! // just do all transChange tags this way for now
! //				if (type == "supplied")
! 					buf += "{\\i1 ";
! 			}
! 			else if (tag.isEndTag()) {
! 				buf += "}";
! 			}
! 			else {	// empty transChange marker?
! 			}
! 		}
  
! 		else {
! 			return false;  // we still didn't handle token
! 		}
! 	}
! 	return true;
  }