[sword-svn] r2211 - in trunk: include lib/bcppmake src/mgr src/modules/filters

chrislit at www.crosswire.org chrislit at www.crosswire.org
Wed Nov 26 21:42:54 MST 2008


Author: chrislit
Date: 2008-11-26 21:42:53 -0700 (Wed, 26 Nov 2008)
New Revision: 2211

Added:
   trunk/include/osisruby.h
   trunk/src/modules/filters/osisruby.cpp
Modified:
   trunk/lib/bcppmake/libsword.bpf
   trunk/lib/bcppmake/libsword.bpr
   trunk/src/mgr/swmgr.cpp
   trunk/src/modules/filters/Makefile.am
Log:
adding OSISRuby (untested)


Added: trunk/include/osisruby.h
===================================================================
--- trunk/include/osisruby.h	                        (rev 0)
+++ trunk/include/osisruby.h	2008-11-27 04:42:53 UTC (rev 2211)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ *
+ * $Id: osisruby.h 1688 2005-01-01 04:42:26Z scribe $
+ *
+ * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org)
+ *	CrossWire Bible Society
+ *	P. O. Box 2528
+ *	Tempe, AZ  85280-2528
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ */
+
+#ifndef OSISRUBY_H
+#define OSISRUBY_H
+
+#include <swoptfilter.h>
+
+SWORD_NAMESPACE_START
+
+/** This Filter shows/hides headings in a OSIS text
+ */
+class SWDLLEXPORT OSISRuby : public SWOptionFilter {
+public:
+	OSISRuby();
+	virtual ~OSISRuby();
+	virtual char processText(SWBuf &text, const SWKey *key = 0, const SWModule *module = 0);
+};
+
+SWORD_NAMESPACE_END
+#endif

Modified: trunk/lib/bcppmake/libsword.bpf
===================================================================
--- trunk/lib/bcppmake/libsword.bpf	2008-11-12 15:44:45 UTC (rev 2210)
+++ trunk/lib/bcppmake/libsword.bpf	2008-11-27 04:42:53 UTC (rev 2211)
@@ -149,6 +149,8 @@
 USEUNIT("..\..\src\modules\comments\rawcom4\rawcom4.cpp");
 USEUNIT("..\..\src\modules\common\rawverse4.cpp");
 USEUNIT("..\..\src\modules\filters\teihtmlhref.cpp");
+USEUNIT("..\..\src\mgr\versemgr.cpp");
+USEUNIT("..\..\src\modules\filters\osisruby.cpp");
 //---------------------------------------------------------------------------
 #define Library
 

Modified: trunk/lib/bcppmake/libsword.bpr
===================================================================
--- trunk/lib/bcppmake/libsword.bpr	2008-11-12 15:44:45 UTC (rev 2210)
+++ trunk/lib/bcppmake/libsword.bpr	2008-11-27 04:42:53 UTC (rev 2211)
@@ -118,7 +118,8 @@
       ..\..\src\modules\texts\rawtext4\rawtext4.obj 
       ..\..\src\modules\comments\rawcom4\rawcom4.obj 
       ..\..\src\modules\common\rawverse4.obj 
-      ..\..\src\modules\filters\teihtmlhref.obj"/>
+      ..\..\src\modules\filters\teihtmlhref.obj ..\..\src\mgr\versemgr.obj 
+      ..\..\src\modules\filters\osisruby.obj"/>
     <RESFILES value=""/>
     <IDLFILES value=""/>
     <IDLGENFILES value=""/>

Modified: trunk/src/mgr/swmgr.cpp
===================================================================
--- trunk/src/mgr/swmgr.cpp	2008-11-12 15:44:45 UTC (rev 2210)
+++ trunk/src/mgr/swmgr.cpp	2008-11-27 04:42:53 UTC (rev 2211)
@@ -58,6 +58,7 @@
 #include <osislemma.h>
 #include <osisredletterwords.h>
 #include <osismorphsegmentation.h>
+#include <osisruby.h>
 #include <osisscripref.h>
 #include <thmlstrongs.h>
 #include <thmlfootnotes.h>
@@ -177,6 +178,10 @@
 	optionFilters.insert(OptionFilterMap::value_type("OSISMorphSegmentation", tmpFilter));
 	cleanupFilters.push_back(tmpFilter);
 
+	tmpFilter = new OSISRuby();
+	optionFilters.insert(OptionFilterMap::value_type("OSISRuby", tmpFilter));
+	cleanupFilters.push_back(tmpFilter);
+
 	tmpFilter = new ThMLStrongs();
 	optionFilters.insert(OptionFilterMap::value_type("ThMLStrongs", tmpFilter));
 	cleanupFilters.push_back(tmpFilter);

Modified: trunk/src/modules/filters/Makefile.am
===================================================================
--- trunk/src/modules/filters/Makefile.am	2008-11-12 15:44:45 UTC (rev 2210)
+++ trunk/src/modules/filters/Makefile.am	2008-11-27 04:42:53 UTC (rev 2211)
@@ -53,6 +53,7 @@
 OSISFIL += $(filtersdir)/osisvariants.cpp
 OSISFIL += $(filtersdir)/osiswordjs.cpp
 OSISFIL += $(filtersdir)/osismorphsegmentation.cpp
+OSISFIL += $(filtersdir)/osisruby.cpp 
 
 libsword_la_SOURCES += $(filtersdir)/latin1utf8.cpp
 libsword_la_SOURCES += $(filtersdir)/latin1utf16.cpp

Added: trunk/src/modules/filters/osisruby.cpp
===================================================================
--- trunk/src/modules/filters/osisruby.cpp	                        (rev 0)
+++ trunk/src/modules/filters/osisruby.cpp	2008-11-27 04:42:53 UTC (rev 2211)
@@ -0,0 +1,78 @@
+/******************************************************************************
+ *
+ * osisruby          -	SWFilter descendant to hide or show ruby
+ *			in a OSIS module.
+ */
+
+
+#include <stdlib.h>
+#include <osisruby.h>
+#include <utilxml.h>
+
+SWORD_NAMESPACE_START
+
+const char oName[] = "Ruby";
+const char oTip[] = "Toggles Ruby On and Off if they exist";
+
+const SWBuf choices[3] = {"Off", "On", ""};
+const StringList oValues(&choices[0], &choices[2]);
+
+OSISRuby::OSISRuby() : SWOptionFilter(oName, oTip, &oValues) {
+	setOptionValue("Off");
+}
+
+
+OSISRuby::~OSISRuby() {
+}
+
+
+char OSISRuby::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
+	SWBuf token;
+	bool intoken = false;
+	bool lastspace = false;
+
+	const SWBuf orig = text;
+	const char * from = orig.c_str();
+
+	if (!option) {
+		for (text = ""; *from; ++from) {
+			if (*from == '<') {
+				intoken = true;
+				token = "";
+				continue;
+			}
+			if (*from == '>') {	// process tokens
+				intoken = false;
+				if (token.startsWith("w ")) {	// Word
+					XMLTag wtag(token);
+					int count = wtag.getAttributePartCount("gloss", ' ');
+					for (int i = 0; i < count; i++) {
+						SWBuf a = wtag.getAttribute("gloss", i, ' ');
+					}
+					token = wtag;
+					token.trim();
+					// drop <>
+					token << 1;
+					token--;
+				}
+				
+				// keep token in text
+				text.append('<');
+				text.append(token);
+				text.append('>');
+				
+				continue;
+			}
+			if (intoken) {
+				token += *from;
+			}
+			else	{
+				text.append(*from);
+				lastspace = (*from == ' ');
+			}
+		}
+	}
+	return 0;
+}
+
+SWORD_NAMESPACE_END




More information about the sword-cvs mailing list