diff options
Diffstat (limited to 'src/mgr/markupfiltmgr.cpp')
-rw-r--r-- | src/mgr/markupfiltmgr.cpp | 442 |
1 files changed, 233 insertions, 209 deletions
diff --git a/src/mgr/markupfiltmgr.cpp b/src/mgr/markupfiltmgr.cpp index 5dca845..fb12583 100644 --- a/src/mgr/markupfiltmgr.cpp +++ b/src/mgr/markupfiltmgr.cpp @@ -1,9 +1,12 @@ /****************************************************************************** - * swmarkupmgr.cpp - implementaion of class MarkupFilterMgr, subclass of - * used to transcode all module text to a requested - * markup. * - * Copyright 1998 CrossWire Bible Society (http://www.crosswire.org) + * markupfiltmgr.cpp - implementaion of class MarkupFilterMgr, subclass of + * used to transcode all module text to a requested + * markup + * + * $Id: markupfiltmgr.cpp 2980 2013-09-14 21:51:47Z scribe $ + * + * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org) * CrossWire Bible Society * P. O. Box 2528 * Tempe, AZ 85280-2528 @@ -27,7 +30,6 @@ #include <gbfthml.h> #include <thmlhtml.h> #include <gbfhtml.h> -#include <plainhtml.h> #include <thmlhtmlhref.h> #include <gbfhtmlhref.h> #include <teihtmlhref.h> @@ -43,13 +45,19 @@ #include <thmlwebif.h> #include <osiswebif.h> #include <swmodule.h> +#include <thmlxhtml.h> +#include <gbfxhtml.h> +#include <osisxhtml.h> +#include <teixhtml.h> #include <markupfiltmgr.h> #include <swmgr.h> + SWORD_NAMESPACE_START + /****************************************************************************** * MarkupFilterMgr Constructor - initializes instance of MarkupFilterMgr * @@ -58,12 +66,12 @@ SWORD_NAMESPACE_START * mark - Markup format to emit */ -MarkupFilterMgr::MarkupFilterMgr (char mark, char enc) - : EncodingFilterMgr(enc) { +MarkupFilterMgr::MarkupFilterMgr(char mark, char enc) + : EncodingFilterMgr(enc) { - markup = mark; + markup = mark; - CreateFilters(markup); + CreateFilters(markup); } @@ -72,18 +80,14 @@ MarkupFilterMgr::MarkupFilterMgr (char mark, char enc) */ MarkupFilterMgr::~MarkupFilterMgr() { - if (fromthml) - delete (fromthml); - if (fromgbf) - delete (fromgbf); - if (fromplain) - delete (fromplain); - if (fromosis) - delete (fromosis); - if (fromtei) - delete (fromtei); + delete fromthml; + delete fromgbf; + delete fromplain; + delete fromosis; + delete fromtei; } + /****************************************************************************** * MarkupFilterMgr::Markup - sets/gets markup * @@ -92,204 +96,224 @@ MarkupFilterMgr::~MarkupFilterMgr() { * RET: markup */ char MarkupFilterMgr::Markup(char mark) { - if (mark && mark != markup) { - markup = mark; - ModMap::const_iterator module; - - SWFilter * oldplain = fromplain; - SWFilter * oldthml = fromthml; - SWFilter * oldgbf = fromgbf; - SWFilter * oldosis = fromosis; - SWFilter * oldtei = fromtei; - - CreateFilters(markup); - - for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++) - switch (module->second->Markup()) { - case FMT_THML: - if (oldthml != fromthml) { - if (oldthml) { - if (!fromthml) { - module->second->RemoveRenderFilter(oldthml); - } - else { - module->second->ReplaceRenderFilter(oldthml, fromthml); - } - } - else if (fromthml) { - module->second->AddRenderFilter(fromthml); - } - } - break; - case FMT_GBF: - if (oldgbf != fromgbf) { - if (oldgbf) { - if (!fromgbf) { - module->second->RemoveRenderFilter(oldgbf); - } - else { - module->second->ReplaceRenderFilter(oldgbf, fromgbf); - } - } - else if (fromgbf) { - module->second->AddRenderFilter(fromgbf); - } - break; - } - case FMT_PLAIN: - if (oldplain != fromplain) { - if (oldplain) { - if (!fromplain) { - module->second->RemoveRenderFilter(oldplain); - } - else { - module->second->ReplaceRenderFilter(oldplain, fromplain); - } - } - else if (fromplain) { - module->second->AddRenderFilter(fromplain); - } - break; - } - case FMT_OSIS: - if (oldosis != fromosis) { - if (oldosis) { - if (!fromosis) { - module->second->RemoveRenderFilter(oldosis); - } - else { - module->second->ReplaceRenderFilter(oldosis, fromosis); - } - } - else if (fromosis) { - module->second->AddRenderFilter(fromosis); - } - break; - } - case FMT_TEI: - if (oldtei != fromtei) { - if (oldtei) { - if (!fromtei) { - module->second->RemoveRenderFilter(oldtei); - } - else { - module->second->ReplaceRenderFilter(oldtei, fromtei); - } - } - else if (fromtei) { - module->second->AddRenderFilter(fromtei); - } - break; - } - } - - if (oldthml) - delete oldthml; - if (oldgbf) - delete oldgbf; - if (oldplain) - delete oldplain; - if (oldosis) - delete oldosis; - if (oldtei) - delete oldtei; - } - return markup; + if (mark && mark != markup) { + markup = mark; + ModMap::const_iterator module; + + SWFilter *oldplain = fromplain; + SWFilter *oldthml = fromthml; + SWFilter *oldgbf = fromgbf; + SWFilter *oldosis = fromosis; + SWFilter *oldtei = fromtei; + + CreateFilters(markup); + + for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); ++module) { + switch (module->second->getMarkup()) { + case FMT_THML: + if (oldthml != fromthml) { + if (oldthml) { + if (!fromthml) { + module->second->removeRenderFilter(oldthml); + } + else { + module->second->replaceRenderFilter(oldthml, fromthml); + } + } + else if (fromthml) { + module->second->addRenderFilter(fromthml); + } + } + break; + + case FMT_GBF: + if (oldgbf != fromgbf) { + if (oldgbf) { + if (!fromgbf) { + module->second->removeRenderFilter(oldgbf); + } + else { + module->second->replaceRenderFilter(oldgbf, fromgbf); + } + } + else if (fromgbf) { + module->second->addRenderFilter(fromgbf); + } + } + break; + + case FMT_PLAIN: + if (oldplain != fromplain) { + if (oldplain) { + if (!fromplain) { + module->second->removeRenderFilter(oldplain); + } + else { + module->second->replaceRenderFilter(oldplain, fromplain); + } + } + else if (fromplain) { + module->second->addRenderFilter(fromplain); + } + } + break; + + case FMT_OSIS: + if (oldosis != fromosis) { + if (oldosis) { + if (!fromosis) { + module->second->removeRenderFilter(oldosis); + } + else { + module->second->replaceRenderFilter(oldosis, fromosis); + } + } + else if (fromosis) { + module->second->addRenderFilter(fromosis); + } + } + break; + + case FMT_TEI: + if (oldtei != fromtei) { + if (oldtei) { + if (!fromtei) { + module->second->removeRenderFilter(oldtei); + } + else { + module->second->replaceRenderFilter(oldtei, fromtei); + } + } + else if (fromtei) { + module->second->addRenderFilter(fromtei); + } + } + break; + } + } + + delete oldthml; + delete oldgbf; + delete oldplain; + delete oldosis; + delete oldtei; + } + return markup; } + void MarkupFilterMgr::AddRenderFilters(SWModule *module, ConfigEntMap §ion) { - switch (module->Markup()) { - case FMT_THML: - if (fromthml) - module->AddRenderFilter(fromthml); - break; - case FMT_GBF: - if (fromgbf) - module->AddRenderFilter(fromgbf); - break; - case FMT_PLAIN: - if (fromplain) - module->AddRenderFilter(fromplain); - break; - case FMT_OSIS: - if (fromosis) - module->AddRenderFilter(fromosis); - break; - case FMT_TEI: - if (fromtei) - module->AddRenderFilter(fromtei); - break; - } + switch (module->getMarkup()) { + case FMT_THML: + if (fromthml) + module->addRenderFilter(fromthml); + break; + case FMT_GBF: + if (fromgbf) + module->addRenderFilter(fromgbf); + break; + case FMT_PLAIN: + if (fromplain) + module->addRenderFilter(fromplain); + break; + case FMT_OSIS: + if (fromosis) + module->addRenderFilter(fromosis); + break; + case FMT_TEI: + if (fromtei) + module->addRenderFilter(fromtei); + break; + } } + void MarkupFilterMgr::CreateFilters(char markup) { - switch (markup) { - case FMT_PLAIN: - fromplain = NULL; - fromthml = new ThMLPlain(); - fromgbf = new GBFPlain(); - fromosis = new OSISPlain(); - fromtei = new TEIPlain(); - break; - case FMT_THML: - fromplain = NULL; - fromthml = NULL; - fromgbf = new GBFThML(); - fromosis = NULL; - fromtei = NULL; - break; - case FMT_GBF: - fromplain = NULL; - fromthml = new ThMLGBF(); - fromgbf = NULL; - fromosis = NULL; - fromtei = NULL; - break; - case FMT_HTML: - fromplain = new PLAINHTML(); - fromthml = new ThMLHTML(); - fromgbf = new GBFHTML(); - fromosis = NULL; - fromtei = NULL; - break; - case FMT_HTMLHREF: - fromplain = new PLAINHTML(); - fromthml = new ThMLHTMLHREF(); - fromgbf = new GBFHTMLHREF(); - fromosis = new OSISHTMLHREF(); - fromtei = new TEIHTMLHREF(); - break; - case FMT_RTF: - fromplain = NULL; - fromthml = new ThMLRTF(); - fromgbf = new GBFRTF(); - fromosis = new OSISRTF(); - fromtei = new TEIRTF(); - break; - case FMT_OSIS: - fromplain = NULL; - fromthml = new ThMLOSIS(); - fromgbf = new GBFOSIS(); - fromosis = new OSISOSIS(); - fromtei = NULL; - break; - case FMT_WEBIF: - fromplain = NULL; - fromthml = new ThMLWEBIF(); - fromgbf = new GBFWEBIF(); - fromosis = new OSISWEBIF(); - fromtei = NULL; - break; - case FMT_TEI: - fromplain = NULL; - fromthml = NULL; - fromgbf = NULL; - fromosis = NULL; - fromtei = NULL; - break; - } + switch (markup) { + case FMT_PLAIN: + fromplain = NULL; + fromthml = new ThMLPlain(); + fromgbf = new GBFPlain(); + fromosis = new OSISPlain(); + fromtei = new TEIPlain(); + break; + + case FMT_THML: + fromplain = NULL; + fromthml = NULL; + fromgbf = new GBFThML(); + fromosis = NULL; + fromtei = NULL; + break; + + case FMT_GBF: + fromplain = NULL; + fromthml = new ThMLGBF(); + fromgbf = NULL; + fromosis = NULL; + fromtei = NULL; + break; + + case FMT_HTML: + fromplain = NULL; + fromthml = new ThMLHTML(); + fromgbf = new GBFHTML(); + fromosis = NULL; + fromtei = NULL; + break; + + case FMT_HTMLHREF: + fromplain = NULL; + fromthml = new ThMLHTMLHREF(); + fromgbf = new GBFHTMLHREF(); + fromosis = new OSISHTMLHREF(); + fromtei = new TEIHTMLHREF(); + break; + + case FMT_RTF: + fromplain = NULL; + fromthml = new ThMLRTF(); + fromgbf = new GBFRTF(); + fromosis = new OSISRTF(); + fromtei = new TEIRTF(); + break; + + case FMT_OSIS: + fromplain = NULL; + fromthml = new ThMLOSIS(); + fromgbf = new GBFOSIS(); + fromosis = new OSISOSIS(); + fromtei = NULL; + break; + + case FMT_WEBIF: + fromplain = NULL; + fromthml = new ThMLWEBIF(); + fromgbf = new GBFWEBIF(); + fromosis = new OSISWEBIF(); + fromtei = NULL; + break; + + case FMT_TEI: + fromplain = NULL; + fromthml = NULL; + fromgbf = NULL; + fromosis = NULL; + fromtei = NULL; + break; + + case FMT_XHTML: + fromplain = NULL; + fromthml = new ThMLXHTML(); + fromgbf = new GBFXHTML(); + fromosis = new OSISXHTML(); + fromtei = new TEIXHTML(); + break; + } } + SWORD_NAMESPACE_END + |