diff options
author | Roberto C. Sanchez <roberto@connexer.com> | 2014-03-29 10:53:59 -0400 |
---|---|---|
committer | Roberto C. Sanchez <roberto@connexer.com> | 2014-03-29 10:53:59 -0400 |
commit | 03134fa5f6f25d92724ce4c183f9bbe12a9e37dc (patch) | |
tree | 847326a4de82f0241ac87cbbc427a1b92a696a02 /src/modules/texts/swtext.cpp | |
parent | d7469385b05b9510338407fa123e9ad090f80af6 (diff) |
Imported Upstream version 1.5.11
Diffstat (limited to 'src/modules/texts/swtext.cpp')
-rw-r--r-- | src/modules/texts/swtext.cpp | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/src/modules/texts/swtext.cpp b/src/modules/texts/swtext.cpp new file mode 100644 index 0000000..d0ff386 --- /dev/null +++ b/src/modules/texts/swtext.cpp @@ -0,0 +1,113 @@ +/****************************************************************************** + * swtext.cpp - code for base class 'SWText'- The basis for all text modules + */ + +#include <swtext.h> +#include <listkey.h> +#include <localemgr.h> +#include <versekey.h> + +SWORD_NAMESPACE_START + +/****************************************************************************** + * SWText Constructor - Initializes data for instance of SWText + * + * ENT: imodname - Internal name for module + * imoddesc - Name to display to user for module + * idisp - Display object to use for displaying + */ + +SWText::SWText(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang): SWModule(imodname, imoddesc, idisp, (char *)"Biblical Texts", enc, dir, mark, ilang) { + tmpVK = new VerseKey(); + delete key; + key = CreateKey(); + skipConsecutiveLinks = false; +} + + +/****************************************************************************** + * SWText Destructor - Cleans up instance of SWText + */ + +SWText::~SWText() { + delete tmpVK; +} + + +/****************************************************************************** + * SWText CreateKey - Create the correct key (VerseKey) for use with SWText + */ + +SWKey *SWText::CreateKey() { + return new VerseKey(); +} + + +long SWText::Index() const { + VerseKey *key = 0; + SWTRY { + key = SWDYNAMIC_CAST(VerseKey, this->key); + } + SWCATCH ( ... ) {} + if (!key) + key = new VerseKey(this->key); + + entryIndex = key->NewIndex(); + + if (key != this->key) + delete key; + + return entryIndex; +} + +long SWText::Index(long iindex) { + VerseKey *key = 0; + SWTRY { + key = SWDYNAMIC_CAST(VerseKey, this->key); + } + SWCATCH ( ... ) {} + if (!key) + key = new VerseKey(this->key); + + key->Testament(1); + key->Index(iindex); + + if (key != this->key) { + this->key->copyFrom(*key); + delete key; + } + + return Index(); +} + + +VerseKey &SWText::getVerseKey() const { + VerseKey *key = NULL; + // see if we have a VerseKey * or decendant + SWTRY { + key = SWDYNAMIC_CAST(VerseKey, this->key); + } + SWCATCH ( ... ) { } + if (!key) { + ListKey *lkTest = 0; + SWTRY { + lkTest = SWDYNAMIC_CAST(ListKey, this->key); + } + SWCATCH ( ... ) { } + if (lkTest) { + SWTRY { + key = SWDYNAMIC_CAST(VerseKey, lkTest->GetElement()); + } + SWCATCH ( ... ) { } + } + } + if (!key) { + tmpVK->setLocale(LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName()); + (*tmpVK) = *(this->key); + return (*tmpVK); + } + else return *key; +} + + +SWORD_NAMESPACE_END |