[sword-cvs] sword/src/modules/filters osisfootnotes.cpp,1.8,1.9 osisrtf.cpp,1.11,1.12 osisscripref.cpp,1.1,1.2 unicodertf.cpp,1.16,1.17

sword@www.crosswire.org sword@www.crosswire.org
Fri, 4 Jul 2003 18:16:49 -0700


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

Modified Files:
	osisfootnotes.cpp osisrtf.cpp osisscripref.cpp unicodertf.cpp 
Log Message:
Changed entry attribute osis footnotes around to better facilitate separation of crossRefs from other kinds of footnotes

Index: osisfootnotes.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osisfootnotes.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** osisfootnotes.cpp	27 Jun 2003 21:51:50 -0000	1.8
--- osisfootnotes.cpp	5 Jul 2003 01:16:46 -0000	1.9
***************
*** 10,13 ****
--- 10,14 ----
  #include <swmodule.h>
  #include <swbuf.h>
+ #include <versekey.h>
  #include <utilxml.h>
  #ifndef __GNUC__
***************
*** 50,55 ****
--- 51,58 ----
  	SWBuf tagText;
  	XMLTag startTag;
+ 	SWBuf refs = "";
  	int footnoteNum = 1;
  	char buf[254];
+ 	VerseKey parser = key->getText();
  
  	SWBuf orig = text;
***************
*** 75,92 ****
  
  			XMLTag tag(token);
! 			if (!strcmp(tag.getName(), "note") && ((!tag.getAttribute("type")) || (strcmp(tag.getAttribute("type"), "crossReference")))) {
  				if (!tag.isEndTag() && (!tag.isEmpty())) {
  					startTag = tag;
  					hide = true;
  					tagText = "";
- 					if (option) {	// we want the tag in the text
- 						text += '<';
- 						text.append(token);
- 						text += '>';
- 					}
  					continue;
  				}
  				if (hide && tag.isEndTag()) {
! 					if (module->isProcessEntryAttributes() && option) {
  						sprintf(buf, "%i", footnoteNum++);
  						ListString attributes = startTag.getAttributeNames();
--- 78,91 ----
  
  			XMLTag tag(token);
! 			if (!strcmp(tag.getName(), "note")) {
  				if (!tag.isEndTag() && (!tag.isEmpty())) {
+ 					refs = "";
  					startTag = tag;
  					hide = true;
  					tagText = "";
  					continue;
  				}
  				if (hide && tag.isEndTag()) {
! 					if (module->isProcessEntryAttributes()) {
  						sprintf(buf, "%i", footnoteNum++);
  						ListString attributes = startTag.getAttributeNames();
***************
*** 95,114 ****
  						}
  						module->getEntryAttributes()["Footnote"][buf]["body"] = tagText;
! 						if (option) {	// we want the tag in the text
! 							text.append(tagText);
  						}
  					}
  					hide = false;
! 					if (!option) {	// we don't want the tag in the text anymore
! 						continue;
  					}
  				}
  			}
  
  			// if not a heading token, keep token in text
  			if (!hide) {
  				text += '<';
  				text.append(token);
  				text += '>';
  			}
  			continue;
--- 94,129 ----
  						}
  						module->getEntryAttributes()["Footnote"][buf]["body"] = tagText;
! 						startTag.setAttribute("swordFootnote", buf);
! 						if ((startTag.getAttribute("type")) && (!strcmp(startTag.getAttribute("type"), "crossReference"))) {
! 							if (!refs.length())
! 								refs = parser.ParseVerseList(tagText.c_str(), parser, true).getRangeText();
! 							module->getEntryAttributes()["Footnote"][buf]["refList"] = refs.c_str();
  						}
  					}
  					hide = false;
! 					if ((option) || ((startTag.getAttribute("type") && (!strcmp(startTag.getAttribute("type"), "crossReference"))))) {	// we want the tag in the text; crossReferences are handled by another filter
! 						text += startTag;
! 						text.append(tagText);
  					}
+ 					else	continue;
  				}
  			}
  
  			// if not a heading token, keep token in text
+ 			if ((!strcmp(tag.getName(), "reference")) && (!tag.isEndTag())) {
+ 				SWBuf osisRef = tag.getAttribute("osisRef");
+ 				if (refs.length())
+ 					refs += "; ";
+ 				refs += osisRef;
+ 			}
  			if (!hide) {
  				text += '<';
  				text.append(token);
  				text += '>';
+ 			}
+ 			else {
+ 				tagText += '<';
+ 				tagText.append(token);
+ 				tagText += '>';
  			}
  			continue;

Index: osisrtf.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osisrtf.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** osisrtf.cpp	28 Jun 2003 21:31:20 -0000	1.11
--- osisrtf.cpp	5 Jul 2003 01:16:46 -0000	1.12
***************
*** 129,137 ****
  		else if (!strcmp(tag.getName(), "note")) {
  			if (!tag.isEmpty() && !tag.isEndTag()) {
- 				SWBuf 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 descendant
--- 129,136 ----
  		else if (!strcmp(tag.getName(), "note")) {
  			if (!tag.isEmpty() && !tag.isEndTag()) {
  				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
! 					SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
  					VerseKey *vkey;
  					// see if we have a VerseKey * or descendant
***************
*** 141,148 ****
  					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();
  					}
  				}
--- 140,144 ----
  					catch ( ... ) {	}
  					if (vkey) {
! 						buf.appendFormatted("{\\super <a href=\"\">*%c%i.%s</a>} ", ((tag.getAttribute("type") && ((!strcmp(tag.getAttribute("type"), "crossReference")) || (!strcmp(tag.getAttribute("type"), "x-cross-ref")))) ? 'x':'n'), vkey->Verse(), footnoteNumber.c_str());
  					}
  				}
***************
*** 181,185 ****
  
  		// <line> poetry, etc
! 		else if (!strcmp(tag.getName(), "line")) {
  			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
  				buf += "{";
--- 177,181 ----
  
  		// <line> poetry, etc
! 		else if ((!strcmp(tag.getName(), "line")) || ((!strcmp(tag.getName(), "milestone")) && (tag.getAttribute("type")) && (!strcmp(tag.getAttribute("type"), "line")))) {
  			if ((!tag.isEndTag()) && (!tag.isEmpty())) {
  				buf += "{";

Index: osisscripref.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osisscripref.cpp,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** osisscripref.cpp	27 Jun 2003 06:18:05 -0000	1.1
--- osisscripref.cpp	5 Jul 2003 01:16:46 -0000	1.2
***************
*** 65,96 ****
  
  			XMLTag tag(token);
! 			if (!strcmp(tag.getName(), "note") && !strcmp(tag.getAttribute("type"), "crossReference")) {
  				if (!tag.isEndTag() && (!tag.isEmpty())) {
  					startTag = tag;
! 					hide = true;
! 					tagText = "";
! 					if (option) {	// we want the tag in the text
! 						text += '<';
! 						text.append(token);
! 						text += '>';
! 					}
! 					continue;
! 				}
! 				if (hide && tag.isEndTag()) {
! 					if (module->isProcessEntryAttributes() && option) {
! 						sprintf(buf, "%i", footnoteNum++);
! 						ListString attributes = startTag.getAttributeNames();
! 						for (ListString::iterator it = attributes.begin(); it != attributes.end(); it++) {
! 							module->getEntryAttributes()["Footnote"][buf][it->c_str()] = startTag.getAttribute(it->c_str());
! 						}
! 						module->getEntryAttributes()["Footnote"][buf]["body"] = tagText;
  						if (option) {	// we want the tag in the text
! 							text.append(tagText);
  						}
  					}
  					hide = false;
! 					if (!option) {	// we don't want the tag in the text anymore
! 						continue;
  					}
  				}
  			}
--- 65,88 ----
  
  			XMLTag tag(token);
! 			if (!strcmp(tag.getName(), "note")) {
  				if (!tag.isEndTag() && (!tag.isEmpty())) {
  					startTag = tag;
! 					if ((tag.getAttribute("type")) &&	(!strcmp(tag.getAttribute("type"), "crossReference"))) {
! 						hide = true;
! 						tagText = "";
  						if (option) {	// we want the tag in the text
! 							text += '<';
! 							text.append(token);
! 							text += '>';
  						}
+ 						continue;
  					}
+ 				}
+ 				if (hide && tag.isEndTag()) {
  					hide = false;
! 					if (option) {	// we want the tag in the text
! 						text.append(tagText);  // end tag gets added further down
  					}
+ 					else	continue;	// don't let the end tag get added to the text
  				}
  			}
***************
*** 101,104 ****
--- 93,101 ----
  				text.append(token);
  				text += '>';
+ 			}
+ 			else {
+ 				tagText += '<';
+ 				tagText.append(token);
+ 				tagText += '>';
  			}
  			continue;

Index: unicodertf.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/unicodertf.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** unicodertf.cpp	27 Jun 2003 06:13:16 -0000	1.16
--- unicodertf.cpp	5 Jul 2003 01:16:46 -0000	1.17
***************
*** 58,82 ****
  		from += subsequent;
                  if (ch < 0x10000) {
!                         utf16 = (signed short)ch;
!         		text += '\\';
!         		text += 'u';
!         		sprintf(digit, "%d", utf16);
!                         text += digit;
!         		text += '?';
!                 }
!                 else {
!                         utf16 = (signed short)((ch - 0x10000) / 0x400 + 0xD800);
!         		text += '\\';
!         		text += 'u';
!         		sprintf(digit, "%d", utf16);
!                         text += digit;
!         		text += '?';
!                         utf16 = (signed short)((ch - 0x10000) % 0x400 + 0xDC00);
!         		text += '\\';
!         		text += 'u';
!         		sprintf(digit, "%d", utf16);
!                         text += digit;
!         		text += '?';
!                 }
  	}
  	   
--- 58,82 ----
  		from += subsequent;
                  if (ch < 0x10000) {
! 				utf16 = (signed short)ch;
! 				text += '\\';
! 				text += 'u';
! 				sprintf(digit, "%d", utf16);
! 				text += digit;
! 				text += '?';
! 			 }
! 			else {
! 				utf16 = (signed short)((ch - 0x10000) / 0x400 + 0xD800);
! 				text += '\\';
! 				text += 'u';
! 				sprintf(digit, "%d", utf16);
! 				text += digit;
! 				text += '?';
! 				utf16 = (signed short)((ch - 0x10000) % 0x400 + 0xDC00);
! 				text += '\\';
! 				text += 'u';
! 				sprintf(digit, "%d", utf16);
! 				text += digit;
! 				text += '?';
! 			}
  	}