[sword-svn] r2598 - in trunk: include src/mgr

scribe at crosswire.org scribe at crosswire.org
Fri Feb 11 13:28:28 MST 2011


Author: scribe
Date: 2011-02-11 13:28:28 -0700 (Fri, 11 Feb 2011)
New Revision: 2598

Modified:
   trunk/include/swmgr.h
   trunk/src/mgr/swmgr.cpp
Log:
added additional filters for filterText method


Modified: trunk/include/swmgr.h
===================================================================
--- trunk/include/swmgr.h	2011-02-01 02:39:57 UTC (rev 2597)
+++ trunk/include/swmgr.h	2011-02-11 20:28:28 UTC (rev 2598)
@@ -111,6 +111,7 @@
 	SWFilter *teiplain;
 	SWOptionFilter *transliterator;
 	FilterList cleanupFilters;
+	FilterMap extraFilters;
 	StringList options;
 	virtual void init(); // use to initialize before loading modules
 	virtual char AddModToConfig(FileDesc *conffd, const char *fname);

Modified: trunk/src/mgr/swmgr.cpp
===================================================================
--- trunk/src/mgr/swmgr.cpp	2011-02-01 02:39:57 UTC (rev 2597)
+++ trunk/src/mgr/swmgr.cpp	2011-02-11 20:28:28 UTC (rev 2598)
@@ -81,6 +81,7 @@
 #include <swfiltermgr.h>
 #include <swcipher.h>
 #include <swoptfilter.h>
+#include <rtfhtml.h>
 
 #include <swlog.h>
 
@@ -123,6 +124,7 @@
 	cipherFilters.clear();
 	optionFilters.clear();
 	cleanupFilters.clear();
+	extraFilters.clear();
 	tmpFilter = new ThMLVariants();
 	optionFilters.insert(OptionFilterMap::value_type("ThMLVariants", tmpFilter));
 	cleanupFilters.push_back(tmpFilter);
@@ -250,6 +252,12 @@
 
 	teiplain = new TEIPlain();
 	cleanupFilters.push_back(teiplain);
+
+	// filters which aren't really used anywhere but which we want available for a "FilterName" -> filter mapping (e.g., filterText)
+	SWFilter *f = new RTFHTML();
+	extraFilters.insert(FilterMap::value_type("RTFHTML", f));
+	cleanupFilters.push_back(f);
+	
 }
 
 
@@ -1043,12 +1051,23 @@
 char SWMgr::filterText(const char *filterName, SWBuf &text, const SWKey *key, const SWModule *module)
  {
 	char retVal = -1;
+	// why didn't we use find here?
 	for (OptionFilterMap::iterator it = optionFilters.begin(); it != optionFilters.end(); it++) {
 		if ((*it).second->getOptionName()) {
-			if (!stricmp(filterName, (*it).second->getOptionName()))
-				retVal = it->second->processText(text, key, module);	// add filter to module
+			if (!stricmp(filterName, (*it).second->getOptionName())) {
+				retVal = it->second->processText(text, key, module);
+				break;
+			}
 		}
 	}
+
+	if (retVal == -1) {
+		FilterMap::iterator it = extraFilters.find(filterName);
+		if (it != extraFilters.end()) {
+			retVal = it->second->processText(text, key, module);
+		}
+	}
+
 	return retVal;
 }
 




More information about the sword-cvs mailing list