summaryrefslogtreecommitdiff
path: root/apps/windoze/CBuilder5/BibleCS/biblecsmgr.cpp
blob: 04822fc466edfb17b52bbf0ecb970e351f3721d9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//---------------------------------------------------------------------------
#include "BibleCSMGR.h"
#include <swconfig.h>
#include <markupfiltmgr.h>
#ifdef _ICU_
//#include <utf8arshaping.h>
#include <utf8bidireorder.h>
#include <utf8transliterator.h>
#endif
//---------------------------------------------------------------------------
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;
	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
}


void BibleCSMGR::AddRenderFilters(SWModule *module, ConfigEntMap &section)
{
	string lang;
	ConfigEntMap::iterator entry;

	lang = ((entry = section.find("Lang")) != section.end()) ? (*entry).second : (string)"en";

	   if (module->Direction() == 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))) {
				    module->AddRenderFilter(bidireorder);
#endif
			 }
        }
        SWMgr::AddRenderFilters(module, section);
}


char BibleCSMGR::AddModToConfig(int conffd, const char *fname)
{
	SWConfig modconf(fname);
	SectionMap::iterator section;
	AnsiString abouttext = "";
	bool logflag;
	TMemoryStream *RTFStream = new TMemoryStream();
	char retval;

	section = modconf.Sections.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() + " }";
	RTFStream->Clear();
	RTFStream->WriteBuffer(abouttext.c_str(), abouttext.Length());
	RTFStream->Position = 0;
	ModInstFrm->AboutText->Lines->LoadFromStream(RTFStream);
	delete RTFStream;

	ModInstFrm->ShowModal();

	logflag = SWLog::systemlog->log;
	SWLog::systemlog->log = false;
	retval = SWMgr::AddModToConfig(conffd, fname);
	SWLog::systemlog->log = 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
        return retval;
};

void BibleCSMGR::AddGlobalOptions (SWModule * module, ConfigEntMap & section,
							ConfigEntMap::iterator start,
							ConfigEntMap::iterator end) {

	   SWMgr::AddGlobalOptions(module, section, start, end);
#ifdef _ICU_
	   module->AddOptionFilter(transliterator);
#endif
};