MCPcopy Create free account
hub / github.com/buggins/coolreader / InitDoc

Function InitDoc

cr3gui/src/cr3pocketbook.cpp:2330–2481  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2328
2329
2330int InitDoc(const char *exename, char *fileName)
2331{
2332 static const lChar16 * css_file_name = L"fb2.css"; // fb2
2333
2334#ifdef __i386__
2335 CRLog::setStdoutLogger();
2336 CRLog::setLogLevel(CRLog::LL_TRACE);
2337#else
2338 InitCREngineLog(USERDATA"/share/cr3/crlog.ini");
2339#endif
2340
2341 CRLog::trace("InitDoc()");
2342
2343 pbGlobals = new CRPocketBookGlobals(fileName);
2344 char manual_file[512] = USERDATA"/share/c3/manual/cr3-manual-en.fb2";
2345 {
2346 const char *lang = pbGlobals->getLang();
2347
2348 if ( lang && lang[0] ) {
2349 // set translator
2350 CRLog::info("Current language is %s, looking for translation file", lang);
2351 lString16 mofilename = L""USERDATA"/share/cr3/i18n/" + lString16(lang) + L".mo";
2352 lString16 mofilename2 = L""USERDATA2"/share/cr3/i18n/" + lString16(lang) + L".mo";
2353 CRMoFileTranslator * t = new CRMoFileTranslator();
2354 if ( t->openMoFile( mofilename2 ) || t->openMoFile( mofilename ) ) {
2355 CRLog::info("translation file %s.mo found", lang);
2356 CRI18NTranslator::setTranslator( t );
2357 } else {
2358 CRLog::info("translation file %s.mo not found", lang);
2359 delete t;
2360 }
2361 sprintf( manual_file, USERDATA"/share/cr3/manual/cr3-manual-%s.fb2", lang );
2362 if ( !LVFileExists( lString16(manual_file).c_str() ) )
2363 sprintf( manual_file, USERDATA2"/share/cr3/manual/cr3-manual-%s.fb2", lang );
2364 }
2365 }
2366
2367 const lChar16 * ini_fname = L"cr3.ini";
2368#ifdef SEPARATE_INI_FILES
2369 if ( strstr(fileName, ".txt")!=NULL || strstr(fileName, ".tcr")!=NULL) {
2370 ini_fname = L"cr3-txt.ini";
2371 css_file_name = L"txt.css";
2372 } else if ( strstr(fileName, ".rtf")!=NULL ) {
2373 ini_fname = L"cr3-rtf.ini";
2374 css_file_name = L"rtf.css";
2375 } else if ( strstr(fileName, ".htm")!=NULL ) {
2376 ini_fname = L"cr3-htm.ini";
2377 css_file_name = L"htm.css";
2378 } else if ( strstr(fileName, ".epub")!=NULL ) {
2379 ini_fname = L"cr3-epub.ini";
2380 css_file_name = L"epub.css";
2381 } else if ( strstr(fileName, ".doc")!=NULL ) {
2382 ini_fname = L"cr3-doc.ini";
2383 css_file_name = L"doc.css";
2384 } else if ( strstr(fileName, ".chm")!=NULL ) {
2385 ini_fname = L"cr3-chm.ini";
2386 css_file_name = L"chm.css";
2387 } else if ( strstr(fileName, ".pdb")!=NULL ) {

Callers 1

mainFunction · 0.70

Calls 15

lString16Class · 0.85
LVFileExistsFunction · 0.85
loadKeymapsFunction · 0.85
loadPocketBookKeyMapsFunction · 0.85
UnicodeToUtf8Function · 0.85
getLangMethod · 0.80
openMoFileMethod · 0.80
loadSkinMethod · 0.80
setBackgroundColorMethod · 0.80
setHelpFileMethod · 0.80
loadDefaultCoverMethod · 0.80
setBookmarkDirMethod · 0.80

Tested by

no test coverage detected