//--------------------------------------------------------------------------- #include "BibleCSMGR.h" #include #include #include #ifdef _ICU_ //#include #include #include #endif #include "mainfrm.h" using namespace std; //--------------------------------------------------------------------------- BibleCSMGR::BibleCSMGR(TModInstFrm *iModInstFrm) : SWMgr(0, 0, false, new MarkupFilterMgr(FMT_RTF, ENC_RTF)) { #ifdef _ICU_ // arshaping = new UTF8arShaping(); bidireorder = new UTF8BiDiReorder(); // transliterator = new UTF8Transliterator(); #endif ModInstFrm = iModInstFrm; userPrefs = 0; load(); OSVERSIONINFO osvi; memset(&osvi, 0, sizeof(OSVERSIONINFO)); osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); GetVersionEx(&osvi); platformID = osvi.dwPlatformId; } BibleCSMGR::~BibleCSMGR() { #ifdef _ICU_ // if (arshaping) // delete arshaping; if (bidireorder) delete bidireorder; // if (transliterator) // delete transliterator; #endif if (userPrefs) { userPrefs->save(); delete userPrefs; } } void BibleCSMGR::addRenderFilters(SWModule *module, ConfigEntMap §ion) { SWBuf lang; ConfigEntMap::iterator entry; lang = ((entry = section.find("Lang")) != section.end()) ? (*entry).second : (SWBuf)"en"; if (module->getDirection() == DIRECTION_RTL) { #ifdef _ICU_ // if (!strnicmp(lang.c_str(), "ar", 2)) { // module->AddRenderFilter(arshaping); // } if (platformID == WIN9X || (strnicmp(lang.c_str(), "he", 2) && strnicmp(lang.c_str(), "ar", 2) && strnicmp(lang.c_str(), "fa", 2))) { module->addRenderFilter(bidireorder); } #endif } SWMgr::addRenderFilters(module, section); } char BibleCSMGR::addModToConfig(FileDesc *conffd, const char *fname) { SWConfig modconf(fname); SectionMap::iterator section; AnsiString abouttext = ""; int logflag; char retval; section = modconf.getSections().begin(); ModInstFrm->ModText->Caption = ""; ModInstFrm->ModText->Caption = ModInstFrm->ModText->Caption + "Found new module [ " + (*(*section).second.find("Description")).second.c_str() + " ]. Installing..."; abouttext = abouttext + "{\\fs20\\cf0 " + (*(*section).second.find("About")).second.c_str() + " }"; ModInstFrm->AboutText->fillWithRTFString(0, abouttext.c_str()); ModInstFrm->ShowModal(); logflag = SWLog::getSystemLog()->getLogLevel(); SWLog::getSystemLog()->setLogLevel(0); retval = SWMgr::addModToConfig(conffd, fname); SWLog::getSystemLog()->setLogLevel(logflag); return retval; } signed char BibleCSMGR::load() { signed char retval = SWMgr::load(); #ifdef _ICU_ // optionFilters.insert(FilterMap::value_type("UTF8Transliterator", transliterator)); // options.push_back(transliterator->getOptionName()); #endif userPrefs = new SWConfig(TForm1::getDataRootPath()+"/BibleCS/userprefs.conf"); applyUserPrefs(); return retval; }; void BibleCSMGR::applyUserPrefs() { if ((config) && (userPrefs)) (*config) += (*userPrefs); } void BibleCSMGR::addGlobalOptionFilters(SWModule *module, ConfigEntMap §ion) { SWMgr::addGlobalOptionFilters(module, section); #ifdef _ICU_ // module->addOptionFilter(transliterator); #endif }; /* maybe force a section for each module and set a per module userConfig. "But not like this. Not like this." void BibleCSMGR::addLocalOptions(SWModule *module, ConfigEntMap §ion, ConfigEntMap::iterator start, ConfigEntMap::iterator end) { userPrefs[module->Name()]["Font"]; } */