[sword-svn] r2985 - in trunk: bindings/java-jni/jni bindings/objc/ObjCSword.xcodeproj cmake include lib/bcppmake lib/vcppmake src/mgr src/modules/filters
scribe at crosswire.org
scribe at crosswire.org
Fri Oct 4 07:38:14 MST 2013
Author: scribe
Date: 2013-10-04 07:38:14 -0700 (Fri, 04 Oct 2013)
New Revision: 2985
Added:
trunk/include/osisreferencelinks.h
trunk/src/modules/filters/osisreferencelinks.cpp
Modified:
trunk/bindings/java-jni/jni/Android.mk
trunk/bindings/objc/ObjCSword.xcodeproj/project.pbxproj
trunk/cmake/sources.cmake
trunk/lib/bcppmake/libsword.bpf
trunk/lib/vcppmake/libsword.vcxproj
trunk/src/mgr/swmgr.cpp
trunk/src/modules/filters/Makefile.am
Log:
Modified: trunk/bindings/java-jni/jni/Android.mk
===================================================================
--- trunk/bindings/java-jni/jni/Android.mk 2013-09-20 12:18:45 UTC (rev 2984)
+++ trunk/bindings/java-jni/jni/Android.mk 2013-10-04 14:38:14 UTC (rev 2985)
@@ -105,6 +105,7 @@
../../../src/modules/filters/osiswordjs.cpp \
../../../src/modules/filters/osisxhtml.cpp \
../../../src/modules/filters/osisxlit.cpp \
+../../../src/modules/filters/osisreferencelinks.cpp \
../../../src/modules/filters/thmlmorph.cpp \
../../../src/modules/filters/gbfplain.cpp \
../../../src/modules/filters/gbfhtmlhref.cpp \
Modified: trunk/bindings/objc/ObjCSword.xcodeproj/project.pbxproj
===================================================================
--- trunk/bindings/objc/ObjCSword.xcodeproj/project.pbxproj 2013-09-20 12:18:45 UTC (rev 2984)
+++ trunk/bindings/objc/ObjCSword.xcodeproj/project.pbxproj 2013-10-04 14:38:14 UTC (rev 2985)
@@ -338,6 +338,7 @@
A96C235A176AFA3C008D714B /* osisenum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A96C2353176AF19C008D714B /* osisenum.cpp */; };
A96C235B176AFA3C008D714B /* osisglosses.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A96C2354176AF19C008D714B /* osisglosses.cpp */; };
A96C235C176AFA3C008D714B /* osisxlit.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A96C2355176AF19C008D714B /* osisxlit.cpp */; };
+ A96C235C176AFA3C008D714B /* osisreferencelinks.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A96C2355176AF19C008D714B /* osisreferencelinks.cpp */; };
A96C235D176AFA3C008D714B /* gzclose.c in Sources */ = {isa = PBXBuildFile; fileRef = A96C233E176AF139008D714B /* gzclose.c */; };
A96C235E176AFA3C008D714B /* gzlib.c in Sources */ = {isa = PBXBuildFile; fileRef = A96C2340176AF139008D714B /* gzlib.c */; };
A96C235F176AFA3C008D714B /* gzread.c in Sources */ = {isa = PBXBuildFile; fileRef = A96C2341176AF139008D714B /* gzread.c */; };
@@ -1125,6 +1126,7 @@
A96C2353176AF19C008D714B /* osisenum.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = osisenum.cpp; sourceTree = "<group>"; };
A96C2354176AF19C008D714B /* osisglosses.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = osisglosses.cpp; sourceTree = "<group>"; };
A96C2355176AF19C008D714B /* osisxlit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = osisxlit.cpp; sourceTree = "<group>"; };
+ A96C2355176AF19C008D714B /* osisreferencelinks.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = osisreferencelinks.cpp; sourceTree = "<group>"; };
A975EAC411C77862007C1532 /* ObjCSword.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ObjCSword.h; sourceTree = "<group>"; };
A975ED9811C7925C007C1532 /* imp2gbs.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = imp2gbs.cpp; sourceTree = "<group>"; };
A975ED9911C7925C007C1532 /* imp2ld.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = imp2ld.cpp; sourceTree = "<group>"; };
@@ -1700,6 +1702,7 @@
A96C2353176AF19C008D714B /* osisenum.cpp */,
A96C2354176AF19C008D714B /* osisglosses.cpp */,
A96C2355176AF19C008D714B /* osisxlit.cpp */,
+ A96C2355176AF19C008D714B /* osisreferencelinks.cpp */,
A9E9C5ED16806A2B00ECEB39 /* teixhtml.cpp */,
A954A85513EE98B30094E3FE /* cipherfil.cpp */,
A954A85613EE98B30094E3FE /* gbffootnotes.cpp */,
@@ -2855,6 +2858,7 @@
A96C235A176AFA3C008D714B /* osisenum.cpp in Sources */,
A96C235B176AFA3C008D714B /* osisglosses.cpp in Sources */,
A96C235C176AFA3C008D714B /* osisxlit.cpp in Sources */,
+ A96C235C176AFA3C008D714B /* osisreferencelinks.cpp in Sources */,
A96C235D176AFA3C008D714B /* gzclose.c in Sources */,
A96C235E176AFA3C008D714B /* gzlib.c in Sources */,
A96C235F176AFA3C008D714B /* gzread.c in Sources */,
Modified: trunk/cmake/sources.cmake
===================================================================
--- trunk/cmake/sources.cmake 2013-09-20 12:18:45 UTC (rev 2984)
+++ trunk/cmake/sources.cmake 2013-10-04 14:38:14 UTC (rev 2985)
@@ -119,6 +119,7 @@
src/modules/filters/osisvariants.cpp
src/modules/filters/osiswordjs.cpp
src/modules/filters/osismorphsegmentation.cpp
+ src/modules/filters/osisreferencelinks.cpp
src/modules/filters/latin1utf8.cpp
src/modules/filters/latin1utf16.cpp
@@ -302,6 +303,7 @@
include/osisscripref.h
include/osiswordjs.h
include/osisvariants.h
+ include/osisreferencelinks.h
include/papyriplain.h
include/rawcom.h
Added: trunk/include/osisreferencelinks.h
===================================================================
--- trunk/include/osisreferencelinks.h (rev 0)
+++ trunk/include/osisreferencelinks.h 2013-10-04 14:38:14 UTC (rev 2985)
@@ -0,0 +1,56 @@
+/******************************************************************************
+ *
+ * osisreferencelinks.h -
+ *
+ * $Id: osisreferencelinks.h 1688 2005-01-01 04:42:26Z $
+ *
+ * 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.
+ *
+ * modified: 2009 by John Austin
+ *
+ */
+
+#ifndef OSISREFERENCELINKS_H
+#define OSISREFERENCELINKS_H
+
+#include <swoptfilter.h>
+
+SWORD_NAMESPACE_START
+
+/** This Filter hides reference links with a particular type/subtype in an OSIS text
+ */
+class SWDLLEXPORT OSISReferenceLinks : public SWOptionFilter {
+ SWBuf optionName;
+ SWBuf optionTip;
+ SWBuf type;
+ SWBuf subType;
+public:
+
+ /**
+ * @param optionName - name of this option
+ * @param optionTip - user help tip for this option
+ * @param type - which reference types to hide
+ * @param subType - which reference subTypes to hide (optional)
+ * @param defaultValue - default value of option "On" or "Off" (optional)
+ */
+ OSISReferenceLinks(const char *optionName, const char *optionTip, const char *type, const char *subType = 0, const char *defaultValue = "On");
+ virtual ~OSISReferenceLinks();
+ 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 2013-09-20 12:18:45 UTC (rev 2984)
+++ trunk/lib/bcppmake/libsword.bpf 2013-10-04 14:38:14 UTC (rev 2985)
@@ -159,6 +159,7 @@
USEUNIT("..\..\src\modules\common\bz2comprs.cpp");
USEUNIT("..\..\src\modules\filters\osisvariants.cpp");
USEUNIT("..\..\src\modules\filters\osisxlit.cpp");
+USEUNIT("..\..\src\modules\filters\osisreferencelinks.cpp");
USEUNIT("..\..\src\modules\filters\scsuutf8.cpp");
//---------------------------------------------------------------------------
#define Library
Modified: trunk/lib/vcppmake/libsword.vcxproj
===================================================================
--- trunk/lib/vcppmake/libsword.vcxproj 2013-09-20 12:18:45 UTC (rev 2984)
+++ trunk/lib/vcppmake/libsword.vcxproj 2013-10-04 14:38:14 UTC (rev 2985)
@@ -139,6 +139,7 @@
<ClCompile Include="..\..\src\modules\filters\osisenum.cpp" />
<ClCompile Include="..\..\src\modules\filters\osisglosses.cpp" />
<ClCompile Include="..\..\src\modules\filters\osisxlit.cpp" />
+ <ClCompile Include="..\..\src\modules\filters\osisreferencelinks.cpp" />
<ClCompile Include="..\..\src\modules\filters\scsuutf8.cpp" />
<ClCompile Include="..\..\src\utilfuns\win32\dirent.cpp" />
<ClCompile Include="..\..\src\mgr\encfiltmgr.cpp" />
@@ -362,6 +363,7 @@
<ClInclude Include="..\..\include\osiswordjs.h" />
<ClInclude Include="..\..\include\osisxhtml.h" />
<ClInclude Include="..\..\include\osisxlit.h" />
+ <ClInclude Include="..\..\include\osisreferencelinks.h" />
<ClInclude Include="..\..\include\papyriplain.h" />
<ClInclude Include="..\..\include\rawcom.h" />
<ClInclude Include="..\..\include\rawcom4.h" />
Modified: trunk/src/mgr/swmgr.cpp
===================================================================
--- trunk/src/mgr/swmgr.cpp 2013-09-20 12:18:45 UTC (rev 2984)
+++ trunk/src/mgr/swmgr.cpp 2013-10-04 14:38:14 UTC (rev 2985)
@@ -63,6 +63,7 @@
#include <osisscripref.h>
#include <osisvariants.h>
#include <osisxlit.h>
+#include <osisreferencelinks.h>
#include <thmlstrongs.h>
#include <thmlfootnotes.h>
#include <thmlheadings.h>
@@ -1071,9 +1072,35 @@
void SWMgr::AddGlobalOptions(SWModule *module, ConfigEntMap §ion, ConfigEntMap::iterator start, ConfigEntMap::iterator end) {
- for (;start != end; start++) {
+
+ for (;start != end; ++start) {
OptionFilterMap::iterator it;
- it = optionFilters.find((*start).second);
+ SWBuf filterName = start->second;
+
+
+ // special cases for filters with parameters
+
+ if (filterName.startsWith("OSISReferenceLinks")) {
+ SWBuf params = filterName;
+ filterName = params.stripPrefix('|', true);
+ SWBuf optionName = params.stripPrefix('|', true);
+ SWBuf optionTip = params.stripPrefix('|', true);
+ SWBuf optionType = params.stripPrefix('|', true);
+ SWBuf optionSubType = params.stripPrefix('|', true);
+ SWBuf optionDefaultValue = params.stripPrefix('|', true);
+ // we'll key off of type and subtype.
+ filterName = filterName + "." + optionType + "." + optionSubType;
+
+ it = optionFilters.find(filterName);
+ if (it == optionFilters.end()) {
+ SWOptionFilter *tmpFilter = new OSISReferenceLinks(optionName, optionTip, optionType, optionSubType, optionDefaultValue);
+ optionFilters.insert(OptionFilterMap::value_type(filterName, tmpFilter));
+ cleanupFilters.push_back(tmpFilter);
+ }
+ }
+
+
+ it = optionFilters.find(filterName);
if (it != optionFilters.end()) {
module->addOptionFilter((*it).second); // add filter to module and option as a valid option
StringList::iterator loop;
@@ -1244,15 +1271,15 @@
if (newmod) {
// Filters to add for this module and globally announce as an option to the user
// e.g. translit, strongs, redletterwords, etc, so users can turn these on and off globally
- start = (*it).second.lower_bound("GlobalOptionFilter");
- end = (*it).second.upper_bound("GlobalOptionFilter");
+ start = section.lower_bound("GlobalOptionFilter");
+ end = section.upper_bound("GlobalOptionFilter");
AddGlobalOptions(newmod, section, start, end);
// Only add the option to the module, don't announce it's availability
// These are useful for like: filters that parse special entryAttribs in a text
// or whatever you might want to happen on entry lookup
- start = (*it).second.lower_bound("LocalOptionFilter");
- end = (*it).second.upper_bound("LocalOptionFilter");
+ start = section.lower_bound("LocalOptionFilter");
+ end = section.upper_bound("LocalOptionFilter");
AddLocalOptions(newmod, section, start, end);
//STRIP FILTERS
@@ -1262,8 +1289,8 @@
// Any special processing for this module when searching:
// e.g. for papyri, removed all [](). notation
- start = (*it).second.lower_bound("LocalStripFilter");
- end = (*it).second.upper_bound("LocalStripFilter");
+ start = section.lower_bound("LocalStripFilter");
+ end = section.upper_bound("LocalStripFilter");
AddStripFilters(newmod, section, start, end);
AddRawFilters(newmod, section);
Modified: trunk/src/modules/filters/Makefile.am
===================================================================
--- trunk/src/modules/filters/Makefile.am 2013-09-20 12:18:45 UTC (rev 2984)
+++ trunk/src/modules/filters/Makefile.am 2013-10-04 14:38:14 UTC (rev 2985)
@@ -60,6 +60,7 @@
OSISFIL += $(filtersdir)/osisglosses.cpp
OSISFIL += $(filtersdir)/osisenum.cpp
OSISFIL += $(filtersdir)/osisxlit.cpp
+OSISFIL += $(filtersdir)/osisreferencelinks.cpp
libsword_la_SOURCES += $(filtersdir)/latin1utf8.cpp
libsword_la_SOURCES += $(filtersdir)/latin1utf16.cpp
Added: trunk/src/modules/filters/osisreferencelinks.cpp
===================================================================
--- trunk/src/modules/filters/osisreferencelinks.cpp (rev 0)
+++ trunk/src/modules/filters/osisreferencelinks.cpp 2013-10-04 14:38:14 UTC (rev 2985)
@@ -0,0 +1,100 @@
+/******************************************************************************
+ *
+ * OSISReferenceLinks
+ * modified: 2009 by John Austin
+ * SWFilter descendant to toggle OSIS reference links with
+ * specified type/subType
+ */
+
+
+#include <stdlib.h>
+#include <osisreferencelinks.h>
+#include <utilxml.h>
+#include <swmodule.h>
+
+
+SWORD_NAMESPACE_START
+
+
+namespace {
+
+ static const StringList *oValues() {
+ static const SWBuf choices[3] = {"On", "Off", ""};
+ static const StringList oVals(&choices[0], &choices[2]);
+ return &oVals;
+ }
+}
+
+
+OSISReferenceLinks::OSISReferenceLinks(const char *optionName, const char *optionTip, const char *type, const char *subType, const char *defaultValue)
+ : SWOptionFilter(),
+ optionName(optionName),
+ optionTip(optionTip),
+ type(type),
+ subType(subType) {
+
+ optName = this->optionName.c_str();
+ optTip = this->optionTip.c_str();
+ optValues = oValues();
+ setOptionValue(defaultValue);
+}
+
+
+OSISReferenceLinks::~OSISReferenceLinks() {
+}
+
+
+char OSISReferenceLinks::processText(SWBuf &text, const SWKey *key, const SWModule *module) {
+ if (option) return 0;
+
+ SWBuf token;
+ bool intoken = false;
+ bool stripThisToken = false;
+
+ 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, "reference", 9) && strncmp(token.c_str(), "/reference", 10)) {
+ text.append('<');
+ text.append(token);
+ text.append('>');
+ }
+ else {
+ XMLTag tag;
+ tag = token;
+ if (!tag.isEndTag() && type == tag.getAttribute("type") && (!subType.size() || subType == tag.getAttribute("subType"))) {
+ stripThisToken = true;
+ continue;
+ }
+ else if (tag.isEndTag() && stripThisToken) {
+ stripThisToken = false;
+ continue;
+ }
+ text.append('<');
+ text.append(token);
+ text.append('>');
+ }
+ continue;
+ }
+
+ if (intoken) { //copy token
+ token.append(*from);
+ }
+ else { //copy text which is not inside a token
+ text.append(*from);
+ }
+ }
+ return 0;
+}
+
+SWORD_NAMESPACE_END
+
+
More information about the sword-cvs
mailing list