diff options
author | Roberto C. Sanchez <roberto@connexer.com> | 2014-03-29 10:54:01 -0400 |
---|---|---|
committer | Roberto C. Sanchez <roberto@connexer.com> | 2014-03-29 10:54:01 -0400 |
commit | 71a39f4652cd51df814c930dd268f3c9ad2aee86 (patch) | |
tree | 5994350a603908c4e4d660bc9d72c4ec43dd648e /src/modules/texts/swtext.cpp | |
parent | 03134fa5f6f25d92724ce4c183f9bbe12a9e37dc (diff) |
Imported Upstream version 1.6.0+dfsg
Diffstat (limited to 'src/modules/texts/swtext.cpp')
-rw-r--r-- | src/modules/texts/swtext.cpp | 80 |
1 files changed, 47 insertions, 33 deletions
diff --git a/src/modules/texts/swtext.cpp b/src/modules/texts/swtext.cpp index d0ff386..a7f5f92 100644 --- a/src/modules/texts/swtext.cpp +++ b/src/modules/texts/swtext.cpp @@ -1,7 +1,24 @@ /****************************************************************************** * swtext.cpp - code for base class 'SWText'- The basis for all text modules + * + * + * Copyright 2009 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. + * */ +#include <utilstr.h> #include <swtext.h> #include <listkey.h> #include <localemgr.h> @@ -17,10 +34,14 @@ SWORD_NAMESPACE_START * 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(); +SWText::SWText(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWTextEncoding enc, SWTextDirection dir, SWTextMarkup mark, const char* ilang, const char *versification): SWModule(imodname, imoddesc, idisp, "Biblical Texts", enc, dir, mark, ilang) { + this->versification = 0; + stdstr(&(this->versification), versification); delete key; - key = CreateKey(); + key = (VerseKey *)CreateKey(); + tmpVK1 = (VerseKey *)CreateKey(); + tmpVK2 = (VerseKey *)CreateKey(); + tmpSecond = false; skipConsecutiveLinks = false; } @@ -30,7 +51,9 @@ SWText::SWText(const char *imodname, const char *imoddesc, SWDisplay *idisp, SWT */ SWText::~SWText() { - delete tmpVK; + delete tmpVK1; + delete tmpVK2; + delete [] versification; } @@ -38,60 +61,49 @@ SWText::~SWText() { * SWText CreateKey - Create the correct key (VerseKey) for use with SWText */ -SWKey *SWText::CreateKey() { - return new VerseKey(); -} +SWKey *SWText::CreateKey() const { + VerseKey *vk = new VerseKey(); + vk->setVersificationSystem(versification); -long SWText::Index() const { - VerseKey *key = 0; - SWTRY { - key = SWDYNAMIC_CAST(VerseKey, this->key); - } - SWCATCH ( ... ) {} - if (!key) - key = new VerseKey(this->key); + return vk; +} - entryIndex = key->NewIndex(); - if (key != this->key) - delete key; +long SWText::Index() const { + VerseKey *key = &getVerseKey(); + entryIndex = key->Index(); 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); + VerseKey *key = &getVerseKey(); 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; +VerseKey &SWText::getVerseKey(const SWKey *keyToConvert) const { + const SWKey *thisKey = keyToConvert ? keyToConvert : this->key; + + VerseKey *key = 0; // see if we have a VerseKey * or decendant SWTRY { - key = SWDYNAMIC_CAST(VerseKey, this->key); + key = SWDYNAMIC_CAST(VerseKey, thisKey); } SWCATCH ( ... ) { } if (!key) { ListKey *lkTest = 0; SWTRY { - lkTest = SWDYNAMIC_CAST(ListKey, this->key); + lkTest = SWDYNAMIC_CAST(ListKey, thisKey); } SWCATCH ( ... ) { } if (lkTest) { @@ -102,9 +114,11 @@ VerseKey &SWText::getVerseKey() const { } } if (!key) { - tmpVK->setLocale(LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName()); - (*tmpVK) = *(this->key); - return (*tmpVK); + VerseKey *retKey = (tmpSecond) ? tmpVK1 : tmpVK2; + tmpSecond = !tmpSecond; + retKey->setLocale(LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName()); + (*retKey) = *(thisKey); + return (*retKey); } else return *key; } |