[sword-cvs] sword/src/modules/filters osisfootnotes.cpp,1.2,1.3 osisheadings.cpp,1.3,1.4

sword@www.crosswire.org sword@www.crosswire.org
Wed, 18 Jun 2003 13:15:02 -0700


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

Modified Files:
	osisfootnotes.cpp osisheadings.cpp 
Log Message:
	Joachim added OSISFootnotes.  Added entryAttributes
		parsing in OSISFootnotes
	Added = operator and empty constructor to XMLTag
	Fixed OSISHeadings to passthru non x-preverse note
		bodies



Index: osisfootnotes.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osisfootnotes.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** osisfootnotes.cpp	18 Jun 2003 09:59:11 -0000	1.2
--- osisfootnotes.cpp	18 Jun 2003 20:14:59 -0000	1.3
***************
*** 11,14 ****
--- 11,15 ----
  #include <swmodule.h>
  #include <swbuf.h>
+ #include <utilxml.h>
  #ifndef __GNUC__
  #else
***************
*** 25,29 ****
  
  OSISFootnotes::OSISFootnotes() {
! 	option = false;
  	options.push_back(on);
  	options.push_back(off);
--- 26,30 ----
  
  OSISFootnotes::OSISFootnotes() {
! 	option = true;
  	options.push_back(on);
  	options.push_back(off);
***************
*** 45,87 ****
  
  char OSISFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
! 	if (!option) {	// if we don't want footnotes
! 		bool intoken = false;
! 		bool hide = false;
  
! 		SWBuf token;
! 		SWBuf orig = text;
! 		const char *from = orig.c_str();
! 		for (text = ""; *from; from++) {
! 			if (*from == '<') {
! 				intoken = true;
! 				token = "";
! 				continue;
! 			}
! 			else if (*from == '>') { // process tokens
! 				intoken = false;
! 				if (!strncmp(token.c_str(), "note", 4)) {
! 				  hide = true;
!                                   continue;
  				}
! 				else if (!strncmp(token.c_str(), "/note", 5)) {
! 				  hide = false;
!                                   continue;
  				}
  
! 				// if not a footnote token, keep token in text
! 				if (!hide) {
! 					text += '<';
! 					text += token;
! 					text += '>';
  				}
- 				continue;
  			}
! 			if (intoken) {
! 				token += *from; //copy chars of found token
! 			}
! 			else if (!hide) {
!         			text += *from;
  			}
  		}
  	}
  	return 0;
--- 46,124 ----
  
  char OSISFootnotes::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
! 	SWBuf token;
! 	bool intoken    = false;
! 	bool hide       = false;
! 	SWBuf tagText;
! 	XMLTag startTag;
! 	int tagTextNum  = 1;
! 	int footnoteNum = 1;
! 	char buf[254];
  
! 	SWBuf orig = text;
! 	const char *from = orig.c_str();
! 
! 	for (text = ""; *from; from++) {
! 		if (*from == '<') {
! 			intoken = true;
! 			token = "";
! 			continue;
! 		}
! 		if (*from == '>') {	// process tokens
! 			intoken = false;
! 
! 			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;
! 					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;
! 					}
  				}
  			}
! 
! 			// if not a heading token, keep token in text
! 			if (!hide) {
! 				text += '<';
! 				text.append(token);
! 				text += '>';
  			}
+ 			continue;
+ 		}
+ 		if (intoken) { //copy token
+ 			token += *from;
+ 		}
+ 		else if (!hide) { //copy text which is not inside a token
+ 			text += *from;
  		}
+ 		else tagText += *from;
  	}
  	return 0;

Index: osisheadings.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/src/modules/filters/osisheadings.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** osisheadings.cpp	28 May 2003 07:26:12 -0000	1.3
--- osisheadings.cpp	18 Jun 2003 20:14:59 -0000	1.4
***************
*** 97,100 ****
--- 97,103 ----
  							sprintf(buf, "%i", headerNum++);
  							module->getEntryAttributes()["Heading"]["Interverse"][buf] = header;
+ 							if (option) {	// we want the tag in the text
+ 								text.append(header);
+ 							}
  						}
  					}