//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Main.h" #include #include #include #include #include #include #include //--------------------------------------------------------------------------- #pragma resource "*.dfm" TMainForm *MainForm; //--------------------------------------------------------------------------- __fastcall TMainForm::TMainForm(TComponent* Owner) : TForm(Owner) { } //---------------------------------------------------------------------------- void __fastcall TMainForm::FormCreate(TObject *Sender) { ModMap::iterator it; SWModule *target; manager = new SWMgr(); for (it = manager->Modules.begin(); it != manager->Modules.end(); it++) { target = it->second; if (!strcmp(target->Type(), "Biblical Texts")) { modlist->Items->Add(target->Name()); // if (descriptions) *output << target->Description(); } } for (it = manager->Modules.begin(); it != manager->Modules.end(); it++) { target = it->second; if (!strcmp(target->Type(), "Commentaries")) { modlist->Items->Add(target->Name()); // if (descriptions) *output << target->Description(); } } for (it = manager->Modules.begin(); it != manager->Modules.end(); it++) { target = it->second; if (!strcmp(target->Type(), "Lexicons / Dictionaries")) { modlist->Items->Add(target->Name()); // if (descriptions) *output << target->Description(); } } } short palmbooks[67] = {0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 190, 220, 230, 240, 250, 260, 290, 300, 310, 330, 340, 350, 360, 370, 380, 390, 400, 410, 420, 430, 440, 450, 460, 470, 480, 490, 500, 510, 520, 530, 540, 550, 560, 570, 580, 590, 600, 610, 620, 630, 640, 650, 660, 670, 680, 690, 700, 710, 720, 730}; char* palmbooknames[67] = {"", "GEN", "EXO", "LEV", "NUM", "DEU", "JOS", "JUG", "RUT", "1SA", "2SA", "1KI", "2KI", "1CH", "2CH", "EZR", "NEH", "EST", "JOB", "PS", "PRO", "ECC", "SON", "ISA", "JER", "LAM", "EZE", "DAN", "HOS", "JOE", "AMO", "OBA", "JON", "MIC", "NAH", "HAB", "ZEP", "HAG", "ZEC", "MAL", "MAT", "MAK", "LUK", "JHN", "ACT", "ROM", "1CO", "2CO", "GAL", "EPH", "PHL", "COL", "1TS", "2TS", "1TI", "2TI", "TIT", "MON", "HEB", "JAS", "1PE", "2PE", "1JN", "2JN", "3JN", "JUD", "REV"}; enum {ThML, OLB, GBF, PBR, Plain}; void __fastcall TMainForm::outputClick(TObject *Sender) { static GBFThML gbffilter; static Latin1UTF8 latin1filter; static ThMLOLB olboutputfilter; static ThMLGBF gbfoutputfilter; static ThMLPlain plainoutputfilter; int format; if (fmtOLB->Checked) format = OLB; else if (fmtGBF->Checked) format = GBF; else if (fmtPalm->Checked) format = PBR; else if (fmtPlain->Checked) format = Plain; else format = ThML; unsigned long topicnr = 0; //Turn EVERYTHING on manager->setGlobalOption("Footnotes","On"); manager->setGlobalOption("Headings","On"); manager->setGlobalOption("Strong's Numbers","On"); manager->setGlobalOption("Morphological Tags","On"); manager->setGlobalOption("Hebrew Cantillation","On"); manager->setGlobalOption("Hebrew Vowel Points","On"); manager->setGlobalOption("Greek Accents","On"); if (format == OLB) { manager->setGlobalOption("Headings","Off"); } for (int i = 0; i < modlist->Items->Count; i++) { if (modlist->Checked[i]) { if (feedback->Lines->Count > 30000) { feedback->Lines->Clear(); } AnsiString path; if (format == OLB) path = outputpath->Text + "\\" + modlist->Items->Strings[i] + ".exp"; else if (format == GBF) path = outputpath->Text + "\\" + modlist->Items->Strings[i] + ".gbf"; else if (format == ThML) path = outputpath->Text + "\\" + modlist->Items->Strings[i] + ".thml"; else path = outputpath->Text + "\\" + modlist->Items->Strings[i] + ".txt"; ModMap::iterator it = manager->Modules.find(modlist->Items->Strings[i].c_str()); SectionMap::iterator sit; ConfigEntMap::iterator eit; SWModule *mod = it->second; FILE *ofile = fopen(path.c_str(), "w"); VerseKey* vkey; SWKey* key; char* version; char* lang; bool rtl; static unsigned char testament, book, chapter, verse; static bool t, b, c, v; testament = book = chapter = verse = t = b = c = v = 0; 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 } else { mod->RemoveRenderFilter(&gbffilter); } } 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 } else { mod->RemoveRenderFilter(&latin1filter); // memory leak? never heard of one } } if ((eit = (*sit).second.find("Version")) != (*sit).second.end()) { version = (char *)(*eit).second.c_str(); } else { version = "1.0"; } if ((eit = (*sit).second.find("Lang")) != (*sit).second.end()) { lang = (char *)(*eit).second.c_str(); } else { lang = "en"; } if ((eit = (*sit).second.find("Direction")) != (*sit).second.end()) { rtl = !stricmp((char *)(*eit).second.c_str(), "RtoL"); } else { rtl = false; } } if (format == ThML) { LocaleMgr::systemLocaleMgr.setDefaultLocaleName("en"); fprintf(ofile, "\n\n\n\n"); fprintf(ofile, "\ncrosswire\n\n%s\n%s\n\n", modlist->Items->Strings[i].LowerCase().c_str(), version); fprintf(ofile, "\n%s<\/DC.Title>\n%s<\/DC.Language>\n<\/DC>\n<\/electronicEdInfo>\n<\/ThML.head>\n\n", (char*)mod->Description(), lang); if (!strcmp(mod->Type(), "Biblical Texts") || !strcmp(mod->Type(), "Commentaries")) { fprintf (ofile, "\n", (char*)mod->Name()); key = (*mod); vkey = (VerseKey*)key; vkey->Headings(1); vkey->Persist(1); vkey->setLocale("en"); } else if (!strcmp(mod->Type(), "Lexicons / Dictionaries")) { fprintf (ofile, "\n"); } (*mod) = TOP; bool div1, div2, div3; div1 = div2 = div3 = 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; 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); } if (t || !div1) { if (div1) { fprintf (ofile, "<\/div3>\n<\/div2>\n<\/div1>\n"); div3 = false; div2 = false; } if (testament == 1) { fprintf (ofile, "\n"); div1 = true; } else if (testament == 2) { fprintf (ofile, "\n"); div1 = true; } } if ((b || !div2) && book) { if (div2) { fprintf (ofile, "<\/div3>\n<\/div2>\n"); div3 = false; } fprintf (ofile, "\n\n", vkey->books[testament - 1][book - 1].name, book, vkey->books[testament - 1][book - 1].name); div2 = true; } if ((c || !div3) && chapter) { if (div3) { fprintf (ofile, "<\/div3>\n"); } fprintf (ofile, "\n\n", chapter, chapter, vkey->books[testament - 1][book - 1].name, chapter); div3 = true; } } } if (!strcmp(mod->Type(), "Biblical Texts")) { fprintf (ofile, "%s<\/scripture>\n", (char*)mod->KeyText(), (const char*)(*mod)); (*mod)++; } else if (!strcmp(mod->Type(), "Commentaries")) { fprintf (ofile, "%s<\/scripCom>\n", (char*)mod->KeyText(), (const char*)(*mod)); (*mod)++; } else if (!strcmp(mod->Type(), "Lexicons / Dictionaries")) { fprintf (ofile, "%s<\/term>%s<\/def>\n", (char*)mod->KeyText(), (const char*)(*mod)); (*mod)++; feedback->Lines->Add(modlist->Items->Strings[i] + " - " + (char*)mod->KeyText()); } } if (!strcmp(mod->Type(), "Biblical Texts") || !strcmp(mod->Type(), "Commentaries")) { fprintf (ofile, "<\/div3>\n<\/div2>\n<\/div1>\n"); } else if (!strcmp(mod->Type(), "Lexicons / Dictionaries")) { fprintf (ofile, "<\/glossary>\n"); } fprintf(ofile, "<\/ThML.body>\n<\/ThML>\n"); } else if (format == Plain) { mod->AddRenderFilter(&plainoutputfilter); LocaleMgr::systemLocaleMgr.setDefaultLocaleName("en"); if (!strcmp(mod->Type(), "Biblical Texts") || !strcmp(mod->Type(), "Commentaries")) { key = (*mod); vkey = (VerseKey*)key; vkey->Headings(1); vkey->Persist(1); vkey->setLocale("en"); } (*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")) { fprintf (ofile, "%s %s\n", (char*)mod->KeyText(), (const char*)(*mod)); (*mod)++; } else if (!strcmp(mod->Type(), "Commentaries")) { fprintf (ofile, "%s %s\n", (char*)mod->KeyText(), (const char*)(*mod)); (*mod)++; } else if (!strcmp(mod->Type(), "Lexicons / Dictionaries")) { fprintf (ofile, "%s %s\n", (char*)mod->KeyText(), (const char*)(*mod)); (*mod)++; feedback->Lines->Add(modlist->Items->Strings[i] + " - " + (char*)mod->KeyText()); } } mod->RemoveRenderFilter(&plainoutputfilter); } else if (format == OLB) { mod->AddRenderFilter(&olboutputfilter); LocaleMgr::systemLocaleMgr.setDefaultLocaleName("olb"); if (!strcmp(mod->Type(), "Biblical Texts") || !strcmp(mod->Type(), "Commentaries")) { key = (*mod); vkey = (VerseKey*)key; vkey->Headings(0); vkey->Persist(1); vkey->setLocale("olb"); } (*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")) { fprintf (ofile, "$$$ %s\n%s\n", (char*)mod->KeyText(), (const char*)(*mod)); (*mod)++; } else if (!strcmp(mod->Type(), "Commentaries")) { fprintf (ofile, "$$$ %s\n%s\n", (char*)mod->KeyText(), (const char*)(*mod)); (*mod)++; } else if (!strcmp(mod->Type(), "Lexicons / Dictionaries")) { fprintf (ofile, "$$$ T%d\n\\\\%s\\\\\n%s\n", topicnr++, (char*)mod->KeyText(), (const char*)(*mod)); (*mod)++; feedback->Lines->Add(modlist->Items->Strings[i] + " - " + (char*)mod->KeyText()); } } mod->RemoveRenderFilter(&olboutputfilter); } else if (format == GBF) { if (!strcmp(mod->Type(), "Biblical Texts") || !strcmp(mod->Type(), "Commentaries")) { mod->AddRenderFilter(&gbfoutputfilter); LocaleMgr::systemLocaleMgr.setDefaultLocaleName("en"); fprintf(ofile, "\n

%s\n

%s\n", (char*)mod->Description(), (char*)mod->Name()); key = (*mod); vkey = (VerseKey*)key; vkey->Headings(0); vkey->Persist(1); vkey->setLocale("en"); (*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 (b) { feedback->Lines->Add(modlist->Items->Strings[i] + " - " + vkey->books[testament - 1][book - 1].name); } if (book == 1 && chapter == 1 && verse == 1 && format != PBR) { if (testament == 1) { fprintf (ofile, "\n"); } else if (testament == 2) { fprintf (ofile, "\n"); } fprintf (ofile, "%s\n", book, vkey->books[testament - 1][book - 1].name); fprintf (ofile, "\n", chapter); if (rtl) fprintf (ofile, "\n"); } else if (chapter == 1 && verse == 1) { fprintf (ofile, "%s\n", book, vkey->books[testament - 1][book - 1].name); fprintf (ofile, "\n", chapter); if (rtl) fprintf (ofile, "\n"); } else if (verse == 1) { fprintf (ofile, "\n", chapter); if (rtl) fprintf (ofile, "\n"); } } if (!strcmp(mod->Type(), "Biblical Texts")) { fprintf (ofile, "%s\n", vkey->Verse(), (const char*)(*mod)); (*mod)++; } else if (!strcmp(mod->Type(), "Commentaries")) { fprintf (ofile, "%s\n", vkey->Verse(), (const char*)(*mod)); (*mod)++; } } fprintf(ofile, "\n"); mod->RemoveRenderFilter(&gbfoutputfilter); } } else if (format == PBR) { if (!strcmp(mod->Type(), "Biblical Texts") || !strcmp(mod->Type(), "Commentaries")) { mod->AddRenderFilter(&plainoutputfilter); LocaleMgr::systemLocaleMgr.setDefaultLocaleName(lang); fprintf(ofile, "\n\n"); fprintf(ofile, "\n", (char*)mod->Name(), (char*)mod->Description(), rtl ? "RIGHT" : "LEFT"); key = (*mod); vkey = (VerseKey*)key; vkey->Headings(0); vkey->Persist(1); vkey->setLocale(lang); (*mod) = TOP; 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; } fprintf (ofile, "\n", vkey->books[testament - 1][book - 1].name, palmbooks[book + (39 * (testament - 1))], palmbooknames[book + (39 * (testament - 1))]); div1 = true; b = true; } if (c || !div2) { if (div2) { fprintf(ofile, "<\/CHAPTER>\n"); } fprintf (ofile, "\n"); div2 = true; c = true; } } } if (!strcmp(mod->Type(), "Biblical Texts")) { fprintf (ofile, ""); if (c) { if (b) { fprintf(ofile, "%s", vkey->books[testament - 1][book - 1].name); } fprintf (ofile, "Chapter %d", vkey->Chapter()); } fprintf (ofile, "%s<\/VERSE>\n", (const char*)(*mod)); (*mod)++; } else if (!strcmp(mod->Type(), "Commentaries")) { fprintf (ofile, ""); if (c) { if (b) { fprintf(ofile, "%s", vkey->books[testament - 1][book - 1].name); } fprintf (ofile, "Chapter %d", vkey->Chapter()); } fprintf (ofile, "%s<\/VERSE>\n", (const char*)(*mod)); (*mod)++; } } fprintf(ofile, "<\/CHAPTER>\n<\/BOOK>\n<\/BIBLE>\n"); mod->RemoveRenderFilter(&plainoutputfilter); } } fclose(ofile); feedback->Lines->Add(modlist->Items->Strings[i] + " - Complete"); } } feedback->Lines->Add("All Modules Complete"); } //---------------------------------------------------------------------------