diff options
author | Chris Little <chrislit@crosswire.org> | 2001-10-10 14:54:53 +0000 |
---|---|---|
committer | Chris Little <chrislit@crosswire.org> | 2001-10-10 14:54:53 +0000 |
commit | a9ec509f038d23783755208b3b0d5bee5491a342 (patch) | |
tree | 9eddc826996c61adbdbbf31ef2fb1b49a1b23839 | |
parent | 09ce9af9617d7b1c808ceba994147e181ac7580b (diff) | |
download | sword-tools-a9ec509f038d23783755208b3b0d5bee5491a342.tar.gz |
no message
git-svn-id: https://www.crosswire.org/svn/sword-tools/trunk@7 07627401-56e2-0310-80f4-f8cd0041bdcd
-rw-r--r-- | Diaspora/Diaspora.bpr | 8 | ||||
-rw-r--r-- | Diaspora/Diaspora.res | bin | 1832 -> 8532 bytes | |||
-rw-r--r-- | Diaspora/Main.cpp | 741 | ||||
-rw-r--r-- | Diaspora/Main.dfm | 79 | ||||
-rw-r--r-- | Diaspora/Main.h | 2 |
5 files changed, 640 insertions, 190 deletions
diff --git a/Diaspora/Diaspora.bpr b/Diaspora/Diaspora.bpr index 6e4f0f5..2d34b7e 100644 --- a/Diaspora/Diaspora.bpr +++ b/Diaspora/Diaspora.bpr @@ -52,8 +52,8 @@ IncludeVerInfo=1 AutoIncBuild=1 MajorVer=1 MinorVer=0 -Release=3 -Build=12 +Release=4 +Build=16 Debug=0 PreRelease=0 Special=0 @@ -65,13 +65,13 @@ CodePage=1252 [Version Info Keys] CompanyName=CrossWire Bible Society FileDescription=SWORD Module Exporter -FileVersion=1.0.3.12 +FileVersion=1.0.4.16 InternalName=Diaspora LegalCopyright=Copyright 2001 by CrossWire Bible Society LegalTrademarks= OriginalFilename=diaspora.exe ProductName=Diaspora -ProductVersion=1.0.3 +ProductVersion=1.0.4 Comments=Freely have you been give; freely give. [HistoryLists\hlIncludePath] diff --git a/Diaspora/Diaspora.res b/Diaspora/Diaspora.res Binary files differindex 110e54c..d11cabb 100644 --- a/Diaspora/Diaspora.res +++ b/Diaspora/Diaspora.res diff --git a/Diaspora/Main.cpp b/Diaspora/Main.cpp index e2ac038..df3d931 100644 --- a/Diaspora/Main.cpp +++ b/Diaspora/Main.cpp @@ -10,9 +10,138 @@ #include <thmlolb.h> #include <thmlplain.h> #include <localemgr.h> + +#include <rawtext.h> +#include <rawcom.h> +#include <ztext.h> +#include <zcom.h> //--------------------------------------------------------------------------- #pragma resource "*.dfm" TMainForm *MainForm; + +VerseKey* getVerseBounds (SWModule* mod, VerseKey* key) { + zCom* zcom; + RawCom* rawcom; + zText* ztext; + RawText* rawtext; + + key->LowerBound(mod->Key()); + key->UpperBound(mod->Key()); + + char testament = ((VerseKey*)&mod->Key())->Testament(); + long index = ((VerseKey*)&mod->Key())->Index(); + + long origStart, otherStart, otherIndex; + unsigned short origSize, otherSize; + + zcom = dynamic_cast<zCom*>(mod); + if (zcom) { + + zcom->findoffset(testament, index, &origStart, &origSize); +/* + //work backwards to find first verse outside our block + otherIndex = index - 1; + zcom->findoffset(testament, otherIndex, &otherStart, &otherSize); + while (otherStart == origStart && otherSize == origSize) { + otherIndex--; + zcom->findoffset(testament, otherIndex, &otherStart, &otherSize); + } + key->LowerBound() -= (index - otherIndex - 1); +*/ + //work forwards to find first verse outside our block + otherIndex = index + 1; + zcom->findoffset(testament, otherIndex, &otherStart, &otherSize); + while (otherStart == origStart && otherSize == origSize) { + otherIndex++; + zcom->findoffset(testament, otherIndex, &otherStart, &otherSize); + } + key->UpperBound() += (otherIndex - index - 1); + + } + else { + ztext = dynamic_cast<zText*>(mod); + if (ztext) { + + ztext->findoffset(testament, index, &origStart, &origSize); +/* + //work backwards to find first verse outside our block + otherIndex = index - 1; + ztext->findoffset(testament, otherIndex, &otherStart, &otherSize); + while (otherStart == origStart && otherSize == origSize) { + otherIndex--; + ztext->findoffset(testament, otherIndex, &otherStart, &otherSize); + } + key->LowerBound() -= (index - otherIndex - 1); +*/ + //work forwards to find first verse outside our block + otherIndex = index + 1; + ztext->findoffset(testament, otherIndex, &otherStart, &otherSize); + while (otherStart == origStart && otherSize == origSize) { + otherIndex++; + ztext->findoffset(testament, otherIndex, &otherStart, &otherSize); + } + key->UpperBound() += (otherIndex - index - 1); + + + } + else { + rawcom = dynamic_cast<RawCom*>(mod); + if (rawcom) { + + rawcom->findoffset(testament, index, &origStart, &origSize); +/* + //work backwards to find first verse outside our block + otherIndex = index - 1; + rawcom->findoffset(testament, otherIndex, &otherStart, &otherSize); + while (otherStart == origStart && otherSize == origSize) { + otherIndex--; + rawcom->findoffset(testament, otherIndex, &otherStart, &otherSize); + } + key->LowerBound() -= (index - otherIndex - 1); +*/ + //work forwards to find first verse outside our block + otherIndex = index + 1; + rawcom->findoffset(testament, otherIndex, &otherStart, &otherSize); + while (otherStart == origStart && otherSize == origSize) { + otherIndex++; + rawcom->findoffset(testament, otherIndex, &otherStart, &otherSize); + } + key->UpperBound() += (otherIndex - index - 1); + + } + else { + rawtext = dynamic_cast<RawText*>(mod); + if (rawtext) { + + rawtext->findoffset(testament, index, &origStart, &origSize); +/* + //work backwards to find first verse outside our block + otherIndex = index - 1; + rawtext->findoffset(testament, otherIndex, &otherStart, &otherSize); + while (otherStart == origStart && otherSize == origSize) { + otherIndex--; + rawtext->findoffset(testament, otherIndex, &otherStart, &otherSize); + } + key->LowerBound() -= (index - otherIndex - 1); +*/ + //work forwards to find first verse outside our block + otherIndex = index + 1; + rawtext->findoffset(testament, otherIndex, &otherStart, &otherSize); + while (otherStart == origStart && otherSize == origSize) { + otherIndex++; + rawtext->findoffset(testament, otherIndex, &otherStart, &otherSize); + } + key->UpperBound() += (otherIndex - index - 1); + + + } + } + } + } + + return key; +} + //--------------------------------------------------------------------------- __fastcall TMainForm::TMainForm(TComponent* Owner) : TForm(Owner) @@ -131,13 +260,18 @@ void __fastcall TMainForm::outputClick(TObject *Sender) ConfigEntMap::iterator eit; SWModule *mod = it->second; FILE *ofile = fopen(path.c_str(), "w"); - VerseKey* vkey; + VerseKey* vkey, vkey3; SWKey* key; char* version; char* lang; bool rtl; - static unsigned char testament, book, chapter, verse; + ListKey listkey; + long listi; + bool listfinished, isAtomic; + VerseKey* vkey2; + + static unsigned char testament, book, chapter, verse, verse2; static bool t, b, c, v; testament = book = chapter = verse = t = b = c = v = 0; @@ -145,7 +279,7 @@ void __fastcall TMainForm::outputClick(TObject *Sender) if ((sit = manager->config->Sections.find((*it).second->Name())) != manager->config->Sections.end()) { if ((eit = (*sit).second.find("SourceType")) != (*sit).second.end()) { if (!stricmp((char *)(*eit).second.c_str(), "GBF")) { - mod->AddRenderFilter(&gbffilter); // memory leak? never heard of one + mod->AddRenderFilter(&gbffilter); } else { mod->RemoveRenderFilter(&gbffilter); @@ -153,10 +287,10 @@ void __fastcall TMainForm::outputClick(TObject *Sender) } if ((eit = (*sit).second.find("Encoding")) == (*sit).second.end() || stricmp((char *)(*eit).second.c_str(), "UTF-8")) { if (eit == (*sit).second.end()) { - mod->AddRenderFilter(&latin1filter); // memory leak? never heard of one + mod->AddRenderFilter(&latin1filter); } else { - mod->RemoveRenderFilter(&latin1filter); // memory leak? never heard of one + mod->RemoveRenderFilter(&latin1filter); } } if ((eit = (*sit).second.find("Version")) != (*sit).second.end()) { @@ -196,31 +330,59 @@ void __fastcall TMainForm::outputClick(TObject *Sender) vkey->Headings(1); vkey->Persist(1); vkey->setLocale("en"); + + listfinished = false; + if (!range->Text.IsEmpty()) { + listkey = vkey->ParseVerseList(range->Text.c_str(), "Gen 1:1", true); + listi = 0; + } } else if (!strcmp(mod->Type(), "Lexicons / Dictionaries")) { fprintf (ofile, "<glossary>\n"); } (*mod) = TOP; + if (!strcmp(mod->Type(), "Biblical Texts") || !strcmp(mod->Type(), "Commentaries")) { + if (listkey.Count() > listi) { + vkey = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(listi)); + if (!vkey) { + isAtomic = true; + vkey = (VerseKey*)listkey.GetElement(listi); + } + else { + isAtomic = false; + } + mod->SetKey(vkey); + } + else { + isAtomic = false; + } + } + bool div1, div2, div3; div1 = div2 = div3 = 0; - - while (!mod->Error()) { + + + while (!mod->Error() && !listfinished) { if (!strcmp(mod->Type(), "Biblical Texts") || !strcmp(mod->Type(), "Commentaries")) { + getVerseBounds(mod, &vkey3); + verse2 = vkey3.UpperBound().Verse(); + VerseKey* vkey2 = (VerseKey*)(SWKey*)(*mod); + t = vkey2->Testament() != testament; + testament = vkey2->Testament(); + b = vkey2->Book() != book || t; + book = vkey2->Book(); + c = vkey2->Chapter() != chapter || b; + chapter = vkey2->Chapter(); + v = vkey2->Verse() != verse || c; + verse = vkey2->Verse(); + - t = vkey->Testament() > testament; - testament = vkey->Testament(); - b = vkey->Book() > book; - book = vkey->Book(); - c = vkey->Chapter() > chapter; - chapter = vkey->Chapter(); - v = vkey->Verse() > verse; - verse = vkey->Verse(); if (testament) { if (b && book) { - feedback->Lines->Add(modlist->Items->Strings[i] + " - " + vkey->books[testament - 1][book - 1].name); + feedback->Lines->Add(modlist->Items->Strings[i] + " - " + vkey2->books[testament - 1][book - 1].name); } if (t || !div1) { @@ -243,26 +405,69 @@ void __fastcall TMainForm::outputClick(TObject *Sender) fprintf (ofile, "<\/div3>\n<\/div2>\n"); div3 = false; } - fprintf (ofile, "<div2 title=\"%s\" class=\"book\" n=\"%d\">\n<scripContext passage=\"%s\" \/>\n", vkey->books[testament - 1][book - 1].name, book, vkey->books[testament - 1][book - 1].name); + fprintf (ofile, "<div2 title=\"%s\" class=\"book\" n=\"%d\">\n<scripContext passage=\"%s\" \/>\n", vkey2->books[testament - 1][book - 1].name, book, vkey2->books[testament - 1][book - 1].name); div2 = true; } if ((c || !div3) && chapter) { if (div3) { fprintf (ofile, "<\/div3>\n"); } - fprintf (ofile, "<div3 title=\"Chapter %d\" class=\"chapter\" n=\"%d\">\n<scripContext passage=\"%s %d\" \/>\n", chapter, chapter, vkey->books[testament - 1][book - 1].name, chapter); + fprintf (ofile, "<div3 title=\"Chapter %d\" class=\"chapter\" n=\"%d\">\n<scripContext passage=\"%s %d\" \/>\n", chapter, chapter, vkey2->books[testament - 1][book - 1].name, chapter); div3 = true; } } - } - if (!strcmp(mod->Type(), "Biblical Texts")) { - fprintf (ofile, "<scripture passage=\"%s\">%s<\/scripture>\n", (char*)mod->KeyText(), (const char*)(*mod)); - (*mod)++; - } - else if (!strcmp(mod->Type(), "Commentaries")) { - fprintf (ofile, "<scripCom passage=\"%s\">%s<\/scripCom>\n", (char*)mod->KeyText(), (const char*)(*mod)); - (*mod)++; + if (!strcmp(mod->Type(), "Biblical Texts")) { + if (verse == verse2 || !verse) + fprintf (ofile, "<scripture passage=\"%s\">%s<\/scripture>\n", (char*)mod->KeyText(), (const char*)(*mod)); + else + fprintf (ofile, "<scripture passage=\"%s-%d\">%s<\/scripture>\n", (char*)mod->KeyText(), verse2, (const char*)(*mod)); + } + else if (!strcmp(mod->Type(), "Commentaries")) { + if (verse == verse2 || !verse) + fprintf (ofile, "<scripCom passage=\"%s\">%s<\/scripCom>\n", (char*)mod->KeyText(), (const char*)(*mod)); + else + fprintf (ofile, "<scripCom passage=\"%s-%d\">%s<\/scripCom>\n", (char*)mod->KeyText(), verse2, (const char*)(*mod)); + } + + if (isAtomic || mod->Key() >= vkey->UpperBound()) { + listi++; + if (listkey.Count() > listi) { + vkey = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(listi)); + if (!vkey) { + isAtomic = true; + vkey = (VerseKey*)listkey.GetElement(listi); + } + else { + isAtomic = false; + } + mod->SetKey(vkey); + } + else { + listfinished = true; + } + } + else { + (*mod)++; + if (mod->Key() > vkey->UpperBound()) { + listi++; + if (listkey.Count() > listi) { + vkey = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(listi)); + if (!vkey) { + isAtomic = true; + vkey = (VerseKey*)listkey.GetElement(listi); + } + else { + isAtomic = false; + } + mod->SetKey(vkey); + } + else { + listfinished = true; + } + } + } + } else if (!strcmp(mod->Type(), "Lexicons / Dictionaries")) { fprintf (ofile, "<term>%s<\/term><def>%s<\/def>\n", (char*)mod->KeyText(), (const char*)(*mod)); @@ -282,6 +487,7 @@ void __fastcall TMainForm::outputClick(TObject *Sender) else if (format == Plain) { mod->AddRenderFilter(&plainoutputfilter); LocaleMgr::systemLocaleMgr.setDefaultLocaleName("en"); + fprintf (ofile, ""); // UTF-8 BOM -- a BOM is stupid for an 8-bit encoding, but this does serve to signal that this is UTF-8 and not ANSI if (!strcmp(mod->Type(), "Biblical Texts") || !strcmp(mod->Type(), "Commentaries")) { key = (*mod); @@ -289,29 +495,92 @@ void __fastcall TMainForm::outputClick(TObject *Sender) vkey->Headings(1); vkey->Persist(1); vkey->setLocale("en"); + + listfinished = false; + if (!range->Text.IsEmpty()) { + listkey = vkey->ParseVerseList(range->Text.c_str(), "Gen 1:1", true); + listi = 0; + } } (*mod) = TOP; - while (!mod->Error()) { - testament = vkey->Testament(); - b = vkey->Book() > book; - book = vkey->Book(); - - if (b) { - feedback->Lines->Add(modlist->Items->Strings[i] + " - " + vkey->books[testament - 1][book - 1].name); + if (!strcmp(mod->Type(), "Biblical Texts") || !strcmp(mod->Type(), "Commentaries")) { + if (listkey.Count() > listi) { + vkey = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(listi)); + if (!vkey) { + isAtomic = true; + vkey = (VerseKey*)listkey.GetElement(listi); + } + else { + isAtomic = false; + } + mod->SetKey(vkey); } - - if (!strcmp(mod->Type(), "Biblical Texts")) { - fprintf (ofile, "%s %s\n", (char*)mod->KeyText(), (const char*)(*mod)); - (*mod)++; + else { + isAtomic = false; } - else if (!strcmp(mod->Type(), "Commentaries")) { - fprintf (ofile, "%s %s\n", (char*)mod->KeyText(), (const char*)(*mod)); - (*mod)++; + } + + while (!mod->Error() && !listfinished) { + if (!strcmp(mod->Type(), "Biblical Texts") || !strcmp(mod->Type(), "Commentaries")) { + getVerseBounds(mod, &vkey3); + verse2 = vkey3.UpperBound().Verse(); + VerseKey* vkey2 = (VerseKey*)(SWKey*)(*mod); + testament = vkey2->Testament(); + b = vkey2->Book() != book; + book = vkey2->Book(); + verse = vkey2->Verse(); + + if (b) { + feedback->Lines->Add(modlist->Items->Strings[i] + " - " + vkey2->books[testament - 1][book - 1].name); + } + + if (verse2 == verse || !verse) + fprintf (ofile, "%s %s\n", (char*)mod->KeyText(), (const char*)(*mod)); + else + fprintf (ofile, "%s-%d %s\n", (char*)mod->KeyText(), verse2, (const char*)(*mod)); + + if (isAtomic || mod->Key() >= vkey->UpperBound()) { + listi++; + if (listkey.Count() > listi) { + vkey = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(listi)); + if (!vkey) { + isAtomic = true; + vkey = (VerseKey*)listkey.GetElement(listi); + } + else { + isAtomic = false; + } + mod->SetKey(vkey); + } + else { + listfinished = true; + } + } + else { + (*mod)++; + if (mod->Key() > vkey->UpperBound()) { + listi++; + if (listkey.Count() > listi) { + vkey = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(listi)); + if (!vkey) { + isAtomic = true; + vkey = (VerseKey*)listkey.GetElement(listi); + } + else { + isAtomic = false; + } + mod->SetKey(vkey); + } + else { + listfinished = true; + } + } + } } else if (!strcmp(mod->Type(), "Lexicons / Dictionaries")) { - fprintf (ofile, "%s %s\n", (char*)mod->KeyText(), (const char*)(*mod)); + fprintf (ofile, "%s\n%s\n\n", (char*)mod->KeyText(), (const char*)(*mod)); (*mod)++; feedback->Lines->Add(modlist->Items->Strings[i] + " - " + (char*)mod->KeyText()); } @@ -328,26 +597,86 @@ void __fastcall TMainForm::outputClick(TObject *Sender) vkey->Headings(0); vkey->Persist(1); vkey->setLocale("olb"); + + listfinished = false; + if (!range->Text.IsEmpty()) { + listkey = vkey->ParseVerseList(range->Text.c_str(), "Gen 1:1", true); + listi = 0; + } } (*mod) = TOP; - while (!mod->Error()) { - testament = vkey->Testament(); - b = vkey->Book() > book; - book = vkey->Book(); - - if (b) { - feedback->Lines->Add(modlist->Items->Strings[i] + " - " + vkey->books[testament - 1][book - 1].name); + if (!strcmp(mod->Type(), "Biblical Texts") || !strcmp(mod->Type(), "Commentaries")) { + if (listkey.Count() > listi) { + vkey = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(listi)); + if (!vkey) { + isAtomic = true; + vkey = (VerseKey*)listkey.GetElement(listi); + } + else { + isAtomic = false; + } + mod->SetKey(vkey); } - - if (!strcmp(mod->Type(), "Biblical Texts")) { - fprintf (ofile, "$$$ %s\n%s\n", (char*)mod->KeyText(), (const char*)(*mod)); - (*mod)++; + else { + isAtomic = false; } - else if (!strcmp(mod->Type(), "Commentaries")) { - fprintf (ofile, "$$$ %s\n%s\n", (char*)mod->KeyText(), (const char*)(*mod)); - (*mod)++; + } + + while (!mod->Error() && !listfinished) { + if (!strcmp(mod->Type(), "Biblical Texts") || !strcmp(mod->Type(), "Commentaries")) { + VerseKey* vkey2 = (VerseKey*)(SWKey*)(*mod); + testament = vkey2->Testament(); + b = vkey2->Book() != book; + book = vkey2->Book(); + + if (b) { + feedback->Lines->Add(modlist->Items->Strings[i] + " - " + vkey2->books[testament - 1][book - 1].name); + } + + if (!strcmp(mod->Type(), "Biblical Texts")) + fprintf (ofile, "$$$ %s\n%s\n", (char*)mod->KeyText(), (const char*)(*mod)); + else + fprintf (ofile, "$$$ %s\n%s\n", (char*)mod->KeyText(), (const char*)(*mod)); + + if (isAtomic || mod->Key() >= vkey->UpperBound()) { + listi++; + if (listkey.Count() > listi) { + vkey = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(listi)); + if (!vkey) { + isAtomic = true; + vkey = (VerseKey*)listkey.GetElement(listi); + } + else { + isAtomic = false; + } + mod->SetKey(vkey); + } + else { + listfinished = true; + } + } + else { + (*mod)++; + if (mod->Key() > vkey->UpperBound()) { + listi++; + if (listkey.Count() > listi) { + vkey = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(listi)); + if (!vkey) { + isAtomic = true; + vkey = (VerseKey*)listkey.GetElement(listi); + } + else { + isAtomic = false; + } + mod->SetKey(vkey); + } + else { + listfinished = true; + } + } + } } else if (!strcmp(mod->Type(), "Lexicons / Dictionaries")) { fprintf (ofile, "$$$ T%d\n\\\\%s\\\\\n%s\n", topicnr++, (char*)mod->KeyText(), (const char*)(*mod)); @@ -368,53 +697,107 @@ void __fastcall TMainForm::outputClick(TObject *Sender) vkey->Persist(1); vkey->setLocale("en"); + listfinished = false; + if (!range->Text.IsEmpty()) { + listkey = vkey->ParseVerseList(range->Text.c_str(), "Gen 1:1", true); + listi = 0; + } + (*mod) = TOP; - while (!mod->Error()) { - if (!strcmp(mod->Type(), "Biblical Texts") || !strcmp(mod->Type(), "Commentaries")) { - testament = vkey->Testament(); - b = vkey->Book() > book; - book = vkey->Book(); + if (listkey.Count() > listi) { + vkey = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(listi)); + if (!vkey) { + isAtomic = true; + vkey = (VerseKey*)listkey.GetElement(listi); + } + else { + isAtomic = false; + } + mod->SetKey(vkey); + } + else { + isAtomic = false; + } + + while (!mod->Error() && !listfinished) { + VerseKey* vkey2 = (VerseKey*)(SWKey*)(*mod); + t = vkey2->Testament() != testament; + testament = vkey2->Testament(); + b = vkey2->Book() != book || t; + book = vkey2->Book(); + c = vkey2->Chapter() != chapter || b; + chapter = vkey2->Chapter(); + v = vkey2->Verse() != verse || v; + verse = vkey2->Verse(); + + if (b) { + feedback->Lines->Add(modlist->Items->Strings[i] + " - " + vkey2->books[testament - 1][book - 1].name); + } - if (b) { - feedback->Lines->Add(modlist->Items->Strings[i] + " - " + vkey->books[testament - 1][book - 1].name); + if (t) { + if (testament == 1) { + fprintf (ofile, "<BO><CM>\n"); } + else if (testament == 2) { + fprintf (ofile, "<BN><CM>\n"); + } + + fprintf (ofile, "<SB%d><TT>%s<CM><Tt>\n", book, vkey2->books[testament - 1][book - 1].name); + fprintf (ofile, "<SC%d>\n", chapter); + if (rtl) + fprintf (ofile, "<DR>\n"); + } + else if (b) { + fprintf (ofile, "<SB%d><TT>%s<CM><Tt>\n", book, vkey2->books[testament - 1][book - 1].name); + fprintf (ofile, "<SC%d>\n", chapter); + if (rtl) + fprintf (ofile, "<DR>\n"); + } + else if (c) { + fprintf (ofile, "<SC%d>\n", chapter); + if (rtl) + fprintf (ofile, "<DR>\n"); + } + fprintf (ofile, "<SV%d>%s\n", verse, (const char*)(*mod)); - if (book == 1 && chapter == 1 && verse == 1 && format != PBR) { - if (testament == 1) { - fprintf (ofile, "<BO><CM>\n"); + if (isAtomic || mod->Key() >= vkey->UpperBound()) { + listi++; + if (listkey.Count() > listi) { + vkey = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(listi)); + if (!vkey) { + isAtomic = true; + vkey = (VerseKey*)listkey.GetElement(listi); } - else if (testament == 2) { - fprintf (ofile, "<BN><CM>\n"); + else { + isAtomic = false; } - - fprintf (ofile, "<SB%d><TT>%s<CM><Tt>\n", book, vkey->books[testament - 1][book - 1].name); - fprintf (ofile, "<SC%d>\n", chapter); - if (rtl) - fprintf (ofile, "<DR>\n"); - } - else if (chapter == 1 && verse == 1) { - fprintf (ofile, "<SB%d><TT>%s<CM><Tt>\n", book, vkey->books[testament - 1][book - 1].name); - fprintf (ofile, "<SC%d>\n", chapter); - if (rtl) - fprintf (ofile, "<DR>\n"); + mod->SetKey(vkey); } - else if (verse == 1) { - fprintf (ofile, "<SC%d>\n", chapter); - if (rtl) - fprintf (ofile, "<DR>\n"); + else { + listfinished = true; } } - - - if (!strcmp(mod->Type(), "Biblical Texts")) { - fprintf (ofile, "<SV%d>%s\n", vkey->Verse(), (const char*)(*mod)); - (*mod)++; - } - else if (!strcmp(mod->Type(), "Commentaries")) { - fprintf (ofile, "<SV%d>%s\n", vkey->Verse(), (const char*)(*mod)); + else { (*mod)++; + if (mod->Key() > vkey->UpperBound()) { + listi++; + if (listkey.Count() > listi) { + vkey = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(listi)); + if (!vkey) { + isAtomic = true; + vkey = (VerseKey*)listkey.GetElement(listi); + } + else { + isAtomic = false; + } + mod->SetKey(vkey); + } + else { + listfinished = true; + } + } } } fprintf(ofile, "<ZZ>\n"); @@ -433,94 +816,140 @@ void __fastcall TMainForm::outputClick(TObject *Sender) vkey->Persist(1); vkey->setLocale(lang); + listfinished = false; + if (!range->Text.IsEmpty()) { + listkey = vkey->ParseVerseList(range->Text.c_str(), "Gen 1:1", true); + listi = 0; + } + (*mod) = TOP; + if (listkey.Count() > listi) { + vkey = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(listi)); + if (!vkey) { + isAtomic = true; + vkey = (VerseKey*)listkey.GetElement(listi); + } + else { + isAtomic = false; + } + mod->SetKey(vkey); + } + else { + isAtomic = false; + } + bool div1, div2; div1 = div2 = 0; - while (!mod->Error()) { - if (!strcmp(mod->Type(), "Biblical Texts") || !strcmp(mod->Type(), "Commentaries")) { - t = vkey->Testament() > testament; - testament = vkey->Testament(); - b = vkey->Book() > book || t; - book = vkey->Book(); - c = vkey->Chapter() > chapter || b; - chapter = vkey->Chapter(); - v = vkey->Verse() > verse || v; - verse = vkey->Verse(); - - if (testament) { - if (b) { - feedback->Lines->Add(modlist->Items->Strings[i] + " - " + vkey->books[testament - 1][book - 1].name); - } - - if (b || !div1) { - if (div1) { - fprintf(ofile, "<\/CHAPTER>\n<\/BOOK>\n"); - div2 = false; - } + while (!mod->Error() && !listfinished) { - int len = 2 * strlen(vkey->books[testament - 1][book - 1].name); - char* localname = new char[len]; - strcpy (localname, vkey->books[testament - 1][book - 1].name); - latin1filter.ProcessText(localname, len, NULL); + unsigned char chapter2 = chapter; + verse2 = verse; + VerseKey* vkey2 = (VerseKey*)(SWKey*)(*mod); + t = vkey2->Testament() != testament; + testament = vkey2->Testament(); + b = vkey2->Book() != book || t; + book = vkey2->Book(); + c = vkey2->Chapter() != chapter || b; + chapter = vkey2->Chapter(); + v = vkey2->Verse() != verse || v; + verse = vkey2->Verse(); - fprintf (ofile, "<BOOK NAME=\"%s\" NUMBER=\"%d\" SHORTCUT=\"%s\">\n", localname, palmbooks[book + (39 * (testament - 1))], palmbooknames[book + (39 * (testament - 1))]); - delete localname; + if (testament) { + if (b) { + feedback->Lines->Add(modlist->Items->Strings[i] + " - " + vkey2->books[testament - 1][book - 1].name); + } - div1 = true; - b = true; + if (b || !div1) { + if (div1) { + fprintf(ofile, "<\/CHAPTER>\n<\/BOOK>\n"); + div2 = false; } - if (c || !div2) { - if (div2) { - fprintf(ofile, "<\/CHAPTER>\n"); - } - fprintf (ofile, "<CHAPTER>\n"); - div2 = true; - c = true; + int len = 2 * strlen(vkey2->books[testament - 1][book - 1].name); + char* localname = new char[len]; + strcpy (localname, vkey2->books[testament - 1][book - 1].name); + latin1filter.ProcessText(localname, len, NULL); + + fprintf (ofile, "<BOOK NAME=\"%s\" NUMBER=\"%d\" SHORTCUT=\"%s\">\n", localname, palmbooks[book + (39 * (testament - 1))], palmbooknames[book + (39 * (testament - 1))]); + delete localname; + + div1 = true; + b = true; + } + if (c || !div2) { + if (div2) { + fprintf(ofile, "<\/CHAPTER>\n"); + } + while (chapter - chapter2 - 1 > 0) { + fprintf (ofile, "<CHAPTER><\/CHAPTER>\n"); + chapter2++; } + fprintf (ofile, "<CHAPTER>\n"); + div2 = true; + c = true; } } + for (int j = 0; j < (verse - verse2 - 1); j++) { + fprintf (ofile, "<VERSE><\/VERSE>\n"); + } - if (!strcmp(mod->Type(), "Biblical Texts")) { - fprintf (ofile, "<VERSE>"); - if (c) { - if (b) { - int len = 2 * strlen(vkey->books[testament - 1][book - 1].name); - char* localname = new char[len]; - strcpy (localname, vkey->books[testament - 1][book - 1].name); - latin1filter.ProcessText(localname, len, NULL); + fprintf (ofile, "<VERSE>"); + if (c) { + if (b) { + int len = 2 * strlen(vkey->books[testament - 1][book - 1].name); + char* localname = new char[len]; + strcpy (localname, vkey->books[testament - 1][book - 1].name); + latin1filter.ProcessText(localname, len, NULL); - fprintf(ofile, "<BOOKTEXT>%s", localname); + fprintf(ofile, "<BOOKTEXT>%s", localname); - delete localname; - } - fprintf (ofile, "<CHAPTEXT>Chapter %d<VERSTEXT>", vkey->Chapter()); + delete localname; } - fprintf (ofile, "%s<\/VERSE>\n", (const char*)(*mod)); - - (*mod)++; + fprintf (ofile, "<CHAPTEXT>Chapter %d<VERSTEXT>", chapter); } - else if (!strcmp(mod->Type(), "Commentaries")) { - fprintf (ofile, "<VERSE>"); - if (c) { - if (b) { - int len = 2 * strlen(vkey->books[testament - 1][book - 1].name); - char* localname = new char[len]; - strcpy (localname, vkey->books[testament - 1][book - 1].name); - latin1filter.ProcessText(localname, len, NULL); - - fprintf(ofile, "<BOOKTEXT>%s", localname); - - delete localname; + fprintf (ofile, "%s<\/VERSE>\n", (const char*)(*mod)); + + if (isAtomic || mod->Key() >= vkey->UpperBound()) { + listi++; + if (listkey.Count() > listi) { + vkey = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(listi)); + if (!vkey) { + isAtomic = true; + vkey = (VerseKey*)listkey.GetElement(listi); } - fprintf (ofile, "<CHAPTEXT>Chapter %d<VERSTEXT>", vkey->Chapter()); + else { + isAtomic = false; + } + mod->SetKey(vkey); + } + else { + listfinished = true; } - fprintf (ofile, "%s<\/VERSE>\n", (const char*)(*mod)); + } + else { + (*mod)++; + if (mod->Key() > vkey->UpperBound()) { + listi++; + if (listkey.Count() > listi) { + vkey = SWDYNAMIC_CAST(VerseKey, listkey.GetElement(listi)); + if (!vkey) { + isAtomic = true; + vkey = (VerseKey*)listkey.GetElement(listi); + } + else { + isAtomic = false; + } + mod->SetKey(vkey); + } + else { + listfinished = true; + } + } + } - (*mod)++; } } fprintf(ofile, "<\/CHAPTER>\n<\/BOOK>\n<\/BIBLE>\n"); diff --git a/Diaspora/Main.dfm b/Diaspora/Main.dfm index 964b6c2..7653c2e 100644 --- a/Diaspora/Main.dfm +++ b/Diaspora/Main.dfm @@ -1,8 +1,8 @@ object MainForm: TMainForm - Left = 19 - Top = 23 + Left = 199 + Top = 114 Width = 631 - Height = 461 + Height = 480 Caption = 'Diaspora' Color = clBtnFace Font.Charset = DEFAULT_CHARSET @@ -19,8 +19,10 @@ object MainForm: TMainForm Left = 0 Top = 0 Width = 153 - Height = 434 + Height = 453 Align = alLeft + Constraints.MinHeight = 204 + Constraints.MinWidth = 153 ItemHeight = 13 TabOrder = 0 end @@ -28,9 +30,11 @@ object MainForm: TMainForm Left = 153 Top = 0 Width = 470 - Height = 434 + Height = 453 Align = alClient BevelOuter = bvNone + Constraints.MinHeight = 204 + Constraints.MinWidth = 470 TabOrder = 1 object Label1: TLabel Left = 8 @@ -39,10 +43,17 @@ object MainForm: TMainForm Height = 13 Caption = 'Output Path:' end + object label: TLabel + Left = 8 + Top = 40 + Width = 65 + Height = 13 + Caption = 'Verse Range:' + end object outputpath: TEdit - Left = 93 + Left = 88 Top = 8 - Width = 364 + Width = 377 Height = 21 TabOrder = 0 Text = '.\' @@ -50,18 +61,19 @@ object MainForm: TMainForm object output: TButton Left = 368 Top = 40 - Width = 94 - Height = 41 + Width = 97 + Height = 25 Caption = 'Output Files' TabOrder = 7 OnClick = outputClick end object feedback: TMemo Left = 0 - Top = 143 + Top = 171 Width = 470 - Height = 291 + Height = 282 Align = alBottom + Anchors = [akLeft, akTop, akRight, akBottom] Lines.Strings = ( 'Diaspora: The SWORD Project Module Exporter' 'Copyright 2001 by the CrossWire Bible Society' @@ -94,15 +106,15 @@ object MainForm: TMainForm end object RadioGroup1: TRadioGroup Left = 8 - Top = 40 - Width = 345 + Top = 72 + Width = 457 Height = 41 Caption = 'Format' TabOrder = 1 end object fmtThML: TRadioButton Left = 16 - Top = 56 + Top = 88 Width = 81 Height = 17 Caption = 'ThML' @@ -111,32 +123,32 @@ object MainForm: TMainForm TabStop = True end object fmtOLB: TRadioButton - Left = 88 - Top = 56 + Left = 104 + Top = 88 Width = 49 Height = 17 Caption = 'OLB' TabOrder = 3 end object fmtGBF: TRadioButton - Left = 160 - Top = 56 + Left = 216 + Top = 88 Width = 49 Height = 17 Caption = 'GBF' TabOrder = 4 end object fmtPalm: TRadioButton - Left = 232 - Top = 56 + Left = 320 + Top = 88 Width = 41 Height = 17 Caption = 'PBR' TabOrder = 5 end object fmtPlain: TRadioButton - Left = 296 - Top = 56 + Left = 408 + Top = 88 Width = 41 Height = 17 Caption = 'Plain' @@ -144,7 +156,7 @@ object MainForm: TMainForm end object optFootnotes: TCheckBox Left = 240 - Top = 96 + Top = 120 Width = 81 Height = 17 Caption = 'Footnotes' @@ -154,7 +166,7 @@ object MainForm: TMainForm end object optStrongs: TCheckBox Left = 8 - Top = 96 + Top = 120 Width = 105 Height = 17 Caption = 'Strong'#39's Numbers' @@ -164,7 +176,7 @@ object MainForm: TMainForm end object optHeadings: TCheckBox Left = 344 - Top = 96 + Top = 120 Width = 105 Height = 17 Caption = 'Section Headings' @@ -174,7 +186,7 @@ object MainForm: TMainForm end object optMorph: TCheckBox Left = 128 - Top = 96 + Top = 120 Width = 73 Height = 17 Caption = 'Morphology' @@ -184,7 +196,7 @@ object MainForm: TMainForm end object optGAccents: TCheckBox Left = 344 - Top = 120 + Top = 144 Width = 97 Height = 17 Caption = 'Greek Accents' @@ -194,7 +206,7 @@ object MainForm: TMainForm end object optHCant: TCheckBox Left = 128 - Top = 120 + Top = 144 Width = 113 Height = 17 Caption = 'Hebrew Cantillation' @@ -204,7 +216,7 @@ object MainForm: TMainForm end object optHVowels: TCheckBox Left = 240 - Top = 120 + Top = 144 Width = 97 Height = 17 Caption = 'Hebrew Vowels' @@ -214,12 +226,19 @@ object MainForm: TMainForm end object optRoman: TCheckBox Left = 8 - Top = 120 + Top = 144 Width = 113 Height = 17 Caption = 'Roman Transliterate' Enabled = False TabOrder = 16 end + object range: TEdit + Left = 88 + Top = 40 + Width = 265 + Height = 21 + TabOrder = 17 + end end end diff --git a/Diaspora/Main.h b/Diaspora/Main.h index 62e85d2..4bd6d6d 100644 --- a/Diaspora/Main.h +++ b/Diaspora/Main.h @@ -49,6 +49,8 @@ __published: TCheckBox *optHCant; TCheckBox *optHVowels; TCheckBox *optRoman; + TEdit *range; + TLabel *label; void __fastcall FormCreate(TObject *Sender); void __fastcall outputClick(TObject *Sender); private: // private user declarations |