summaryrefslogtreecommitdiffstats
path: root/bibletime/backend/cswordbackend.cpp
blob: f46b444c48f86b89cc81bf4ae907ef47e30e8c14 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
/*********
*
* This file is part of BibleTime's source code, http://www.bibletime.info/.
*
* Copyright 1999-2006 by the BibleTime developers.
* The BibleTime source code is licensed under the GNU General Public License version 2.0.
*
**********/



//BibleTime includes
#include "cswordbackend.h"
#include "centrydisplay.h"
#include "cbookdisplay.h"
#include "cchapterdisplay.h"
#include "cswordbiblemoduleinfo.h"
#include "cswordcommentarymoduleinfo.h"
#include "cswordlexiconmoduleinfo.h"
#include "cswordbookmoduleinfo.h"

#include "bt_thmlhtml.h"
#include "bt_thmlplain.h"
#include "bt_osishtml.h"
#include "bt_gbfhtml.h"
#include "bt_plainhtml.h"
#include "osismorphsegmentation.h"

#include "frontend/cbtconfig.h"

#include <dirent.h>
#include <unistd.h>
#include <ctype.h>

//Qt includes
#include <qdir.h>
#include <qfileinfo.h>

//KDE includes
#include <klocale.h>
#include <kstringhandler.h>

//Sword includes
#include <swdisp.h>
#include <swfiltermgr.h>
#include <encfiltmgr.h>
#include <rtfhtml.h>
#include <filemgr.h>
#include <utilstr.h>
#include <swfilter.h>

using std::string;

using namespace Filters;

using namespace Rendering;

CSwordBackend::CSwordBackend()
: sword::SWMgr(0, 0, false, new sword::EncodingFilterMgr( sword::ENC_UTF8 ), true) {
	m_displays.entry = 0;
	m_displays.chapter = 0;
	m_displays.book = 0;

	m_filters.gbf = 0;
	m_filters.thml = 0;
	m_filters.osis = 0;
	m_filters.plain = 0;

	filterInit();
}

CSwordBackend::CSwordBackend(const QString& path, const bool augmentHome)
: sword::SWMgr(!path.isEmpty() ? (const char*)path.local8Bit() : 0, false, new sword::EncodingFilterMgr( sword::ENC_UTF8 ), false, augmentHome) // don't allow module renaming, because we load from a path
{
	qDebug("CSwordBackend::CSwordBackend for %s, using %s", path.latin1(), configPath);
	m_displays.entry = 0;
	m_displays.chapter = 0;
	m_displays.book = 0;

	m_filters.gbf = 0;
	m_filters.thml = 0;
	m_filters.osis = 0;
	m_filters.plain = 0;

	filterInit();
}

CSwordBackend::~CSwordBackend() {
	shutdownModules();

	delete m_filters.gbf;
	delete m_filters.plain;
	delete m_filters.thml;
	delete m_filters.osis;

	delete m_displays.book;
	delete m_displays.chapter;
	delete m_displays.entry;
}

/** Initializes the Sword modules. */
const CSwordBackend::LoadError CSwordBackend::initModules() {
	//  qWarning("globalSwordConfigPath is %s", globalConfPath);
	LoadError ret = NoError;

	shutdownModules(); //remove previous modules
	m_moduleList.clear();

	sword::ModMap::iterator end = Modules.end();
	ret = LoadError( Load() );

	for (sword::ModMap::iterator it = Modules.begin(); it != end; it++) {
		sword::SWModule* const curMod = (*it).second;
		CSwordModuleInfo* newModule = 0;

		if (!strcmp(curMod->Type(), "Biblical Texts")) {
			newModule = new CSwordBibleModuleInfo(curMod, this);
			newModule->module()->Disp(
				m_displays.chapter
				? m_displays.chapter
				: (m_displays.chapter = new CChapterDisplay)
			);
		}
		else if (!strcmp(curMod->Type(), "Commentaries")) {
			newModule = new CSwordCommentaryModuleInfo(curMod, this);
			newModule->module()->Disp(
				m_displays.entry
				? m_displays.entry
				: (m_displays.entry = new CEntryDisplay)
			);
		}
		else if (!strcmp(curMod->Type(), "Lexicons / Dictionaries")) {
			newModule = new CSwordLexiconModuleInfo(curMod, this);
			newModule->module()->Disp(
				m_displays.entry
				? m_displays.entry
				: (m_displays.entry = new CEntryDisplay)
			);
		}
		else if (!strcmp(curMod->Type(), "Generic Books")) {
			newModule = new CSwordBookModuleInfo(curMod, this);
			newModule->module()->Disp(
				m_displays.book
				? m_displays.book
				: (m_displays.book = new CBookDisplay)
			);
		}

		if (newModule) { 
			//append the new modules to our list, but only if it's supported
			//the constructor of CSwordModuleInfo prints a waring on stdout
			if (!newModule->hasVersion() || (newModule->minimumSwordVersion() <= sword::SWVersion::currentVersion)) {
				m_moduleList.append( newModule );	
			}
		}
	}

	ListCSwordModuleInfo::iterator end_it = m_moduleList.end();

	for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) {
		// for (m_moduleList.first(); m_moduleList.current(); m_moduleList.next()) {
		m_moduleDescriptionMap.insert( (*it)->config(CSwordModuleInfo::Description), (*it)->name() );
	}

	//unlock modules if keys are present
	//  ListCSwordModuleInfo::iterator end_it = m_moduleList.end();
	for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) {
		//  for (m_moduleList.first(); m_moduleList.current(); m_moduleList.next()) {

		if ( (*it)->isEncrypted() ) {
			const QString unlockKey = CBTConfig::getModuleEncryptionKey( (*it)->name() ).latin1();

			if (!unlockKey.isNull()) {
				setCipherKey( (*it)->name().latin1(), unlockKey.latin1() );
			}
		}
	}

	return ret;
}

void CSwordBackend::AddRenderFilters(sword::SWModule *module, sword::ConfigEntMap &section) {
	sword::SWBuf moduleDriver;
	sword::SWBuf sourceformat;
	sword::ConfigEntMap::iterator entry;
	bool noDriver = true;

	sourceformat = ((entry = section.find("SourceType")) != section.end()) ? (*entry).second : (sword::SWBuf) "";
	moduleDriver = ((entry = section.find("ModDrv")) != section.end()) ? (*entry).second : (sword::SWBuf) "";

	if (sourceformat == "GBF") {
		if (!m_filters.gbf) {
			m_filters.gbf = new BT_GBFHTML();
		}
		module->AddRenderFilter(m_filters.gbf);
		noDriver = false;
	}
	else if (sourceformat == "PLAIN") {
		if (!m_filters.plain) {
			m_filters.plain = new BT_PLAINHTML();
		}
		module->AddRenderFilter(m_filters.plain);
		noDriver = false;
	}
	else if (sourceformat == "ThML") {
		if (!m_filters.thml) {
			m_filters.thml = new BT_ThMLHTML();
		}
		module->AddRenderFilter(m_filters.thml);
		noDriver = false;
	}
	else if (sourceformat == "OSIS") {
		if (!m_filters.osis) {
			m_filters.osis = new BT_OSISHTML();
		}

		module->AddRenderFilter(m_filters.osis);
		noDriver = false;
	}

	if (noDriver) { //no driver found
		if ( (moduleDriver == "RawCom") || (moduleDriver == "RawLD") ) {
			if (!m_filters.plain) {
				m_filters.plain = new BT_PLAINHTML();
			}
			module->AddRenderFilter(m_filters.plain);
			noDriver = false;
		}
	}
}

/** This function deinitializes the modules and deletes them. */
const bool CSwordBackend::shutdownModules() {
	ListCSwordModuleInfo::iterator it = m_moduleList.begin();
	ListCSwordModuleInfo::iterator end = m_moduleList.end();

	while (it != end) {
		CSwordModuleInfo* current = (*it);
		it = m_moduleList.remove(it);

		delete current;
	}

	Q_ASSERT(m_moduleList.count() == 0);

	//BT  mods are deleted now, delete Sword mods, too.
	DeleteMods();

	return true;
}

/** Returns true if the given option is enabled. */
const bool CSwordBackend::isOptionEnabled( const CSwordModuleInfo::FilterTypes type) {
	return (getGlobalOption( optionName(type).latin1() ) == "On");
}

/** Sets the given options enabled or disabled depending on the second parameter. */
void CSwordBackend::setOption( const CSwordModuleInfo::FilterTypes type, const int state ) {
	sword::SWBuf value;

	switch (type) {

		case CSwordModuleInfo::textualVariants:

			if (state == 0) {
				value = "Primary Reading";
			}
			else if (state == 1) {
				value = "Secondary Reading";
			}
			else {
				value = "All Readings";
			}
	
			break;

		default:
			value = state ? "On": "Off";
			break;
	};

	if (value.length())
		setGlobalOption(optionName(type).latin1(), value.c_str());
}

void CSwordBackend::setFilterOptions( const CSwordBackend::FilterOptions options) {
	setOption( CSwordModuleInfo::footnotes,      options.footnotes );
	setOption( CSwordModuleInfo::strongNumbers,    options.strongNumbers );
	setOption( CSwordModuleInfo::headings,       options.headings );
	setOption( CSwordModuleInfo::morphTags,      options.morphTags );
	setOption( CSwordModuleInfo::lemmas,        options.lemmas );
	setOption( CSwordModuleInfo::hebrewPoints,     options.hebrewPoints );
	setOption( CSwordModuleInfo::hebrewCantillation,  options.hebrewCantillation );
	setOption( CSwordModuleInfo::greekAccents,     options.greekAccents );
	setOption( CSwordModuleInfo::redLetterWords,   options.redLetterWords );
	setOption( CSwordModuleInfo::textualVariants,   options.textualVariants );
	setOption( CSwordModuleInfo::morphSegmentation,  options.morphSegmentation );
	//  setOption( CSwordModuleInfo::transliteration,   options.transliteration );
	setOption( CSwordModuleInfo::scriptureReferences, options.scriptureReferences);
}

void CSwordBackend::setDisplayOptions( const CSwordBackend::DisplayOptions ) {
	/*  if (m_displays.entry) {
	  m_displays.entry->setDisplayOptions(options); 
	 }
	  if (m_displays.chapter) {
	  m_displays.chapter->setDisplayOptions(options); 
	 }
	  if (m_displays.book) {
	  m_displays.book->setDisplayOptions(options);
	 }
	 */
}

/** This function searches for a module with the specified description */
CSwordModuleInfo* const CSwordBackend::findModuleByDescription(const QString& description) {
	CSwordModuleInfo* ret = 0;
	ListCSwordModuleInfo::iterator end_it = m_moduleList.end();

	for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) {
		if ( (*it)->config(CSwordModuleInfo::Description) == description ) {
			ret = *it;
			break;
		}
	}

	return ret;
}

/** This function searches for a module with the specified description */
const QString CSwordBackend::findModuleNameByDescription(const QString& description) {
	if (m_moduleDescriptionMap.contains(description)) {
		return m_moduleDescriptionMap[description];
	}

	return QString::null;
}

/** This function searches for a module with the specified name */
CSwordModuleInfo* const CSwordBackend::findModuleByName(const QString& name) {
	CSwordModuleInfo* ret = 0;

	ListCSwordModuleInfo::iterator end_it = m_moduleList.end();

	for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) {
		if ( (*it)->name() == name ) {
			ret = *it;
			break;
		}
	}

	return ret;
}

CSwordModuleInfo* const CSwordBackend::findSwordModuleByPointer(const sword::SWModule* const swmodule) {
	CSwordModuleInfo* ret = 0;
	ListCSwordModuleInfo::iterator end_it = m_moduleList.end();

	for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) {
		if ( (*it)->module() == swmodule ) {
			ret = *it;
			break;
		}
	}
	
	return ret;
}

CSwordModuleInfo* const CSwordBackend::findModuleByPointer(const CSwordModuleInfo* const module) {
	CSwordModuleInfo* ret = 0;

	ListCSwordModuleInfo::iterator end_it = m_moduleList.end();

	for (ListCSwordModuleInfo::iterator it = m_moduleList.begin() ; it != end_it; ++it) {
		if ( (*it)  == module ) {
			ret = *it;
			break;
		}
	}
	
	return ret;
}

/** Returns our local config object to store the cipher keys etc. locally for each user. The values of the config are merged with the global config. */
const bool CSwordBackend::moduleConfig(const QString& module, sword::SWConfig& moduleConfig) {
	sword::SectionMap::iterator section;
	DIR *dir = opendir(configPath);

	struct dirent *ent;

	bool foundConfig = false;
	QString modFile;

	if (dir) {    // find and update .conf file
		rewinddir(dir);

		while ((ent = readdir(dir)) && !foundConfig) {
			if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
				modFile.setLatin1(configPath);
				modFile.append("/");
				modFile.append( QString::fromLocal8Bit(ent->d_name) );

				moduleConfig = sword::SWConfig( (const char*)modFile.local8Bit() );
				section = moduleConfig.Sections.find( (const char*)module.local8Bit() );
				foundConfig = ( section != moduleConfig.Sections.end() );
			}
		}

		closedir(dir);
	}
	else { //try to read mods.conf
		moduleConfig = sword::SWConfig("");//global config
		section = config->Sections.find( (const char*)module.local8Bit() );
		foundConfig = ( section != config->Sections.end() );

		sword::ConfigEntMap::iterator entry;

		if (foundConfig) { //copy module section

			for (entry = (*section).second.begin(); entry != (*section).second.end(); entry++) {
				moduleConfig.Sections[(*section).first].insert(sword::ConfigEntMap::value_type((*entry).first, (*entry).second));
			}
		}
	}

	if (!foundConfig && configType != 2) { //search in $HOME/.sword/
		QString myPath(getenv("HOME"));
		myPath.append("/.sword/mods.d");
		dir = opendir(myPath.latin1());

		if (dir) {
			rewinddir(dir);

			while ((ent = readdir(dir)) && !foundConfig) {
				if ((strcmp(ent->d_name, ".")) && (strcmp(ent->d_name, ".."))) {
					modFile = myPath;
					modFile.append('/');
					modFile.append(ent->d_name);
					moduleConfig = sword::SWConfig( (const char*)modFile.local8Bit() );
					section = moduleConfig.Sections.find( (const char*)module.local8Bit() );
					foundConfig = ( section != moduleConfig.Sections.end() );
				}
			}

			closedir(dir);
		}
	}

	return foundConfig;
}

/** Returns the text used for the option given as parameter. */
const QString CSwordBackend::optionName( const CSwordModuleInfo::FilterTypes option ) {
	switch (option) {

		case CSwordModuleInfo::footnotes:
		return QString("Footnotes");

		case CSwordModuleInfo::strongNumbers:
		return QString("Strong's Numbers");

		case CSwordModuleInfo::headings:
		return QString("Headings");

		case CSwordModuleInfo::morphTags:
		return QString("Morphological Tags");

		case CSwordModuleInfo::lemmas:
		return QString("Lemmas");

		case CSwordModuleInfo::hebrewPoints:
		return QString("Hebrew Vowel Points");

		case CSwordModuleInfo::hebrewCantillation:
		return QString("Hebrew Cantillation");

		case CSwordModuleInfo::greekAccents:
		return QString("Greek Accents");

		case CSwordModuleInfo::redLetterWords:
		return QString("Words of Christ in Red");

		case CSwordModuleInfo::textualVariants:
		return QString("Textual Variants");

		case CSwordModuleInfo::scriptureReferences:
		return QString("Cross-references");

		case CSwordModuleInfo::morphSegmentation:
		return QString("Morph Segmentation");
		//   case CSwordModuleInfo::transliteration:
		//    return QString("Transliteration");
	}

	return QString::null;
}

/** Returns the translated name of the option given as parameter. */
const QString CSwordBackend::translatedOptionName(const CSwordModuleInfo::FilterTypes option) {
	switch (option) {

		case CSwordModuleInfo::footnotes:
		return i18n("Footnotes");

		case CSwordModuleInfo::strongNumbers:
		return i18n("Strong's numbers");

		case CSwordModuleInfo::headings:
		return i18n("Headings");

		case CSwordModuleInfo::morphTags:
		return i18n("Morphological tags");

		case CSwordModuleInfo::lemmas:
		return i18n("Lemmas");

		case CSwordModuleInfo::hebrewPoints:
		return i18n("Hebrew vowel points");

		case CSwordModuleInfo::hebrewCantillation:
		return i18n("Hebrew cantillation marks");

		case CSwordModuleInfo::greekAccents:
		return i18n("Greek accents");

		case CSwordModuleInfo::redLetterWords:
		return i18n("Red letter words");

		case CSwordModuleInfo::textualVariants:
		return i18n("Textual variants");

		case CSwordModuleInfo::scriptureReferences:
		return i18n("Scripture cross-references");

		case CSwordModuleInfo::morphSegmentation:
		return i18n("Morph segmentation");
		//   case CSwordModuleInfo::transliteration:
		//    return i18n("Transliteration between scripts");
	}

	return QString::null;
}


const QString CSwordBackend::configOptionName( const CSwordModuleInfo::FilterTypes option ) {
	switch (option) {

		case CSwordModuleInfo::footnotes:
		return QString("Footnotes");

		case CSwordModuleInfo::strongNumbers:
		return QString("Strongs");

		case CSwordModuleInfo::headings:
		return QString("Headings");

		case CSwordModuleInfo::morphTags:
		return QString("Morph");

		case CSwordModuleInfo::lemmas:
		return QString("Lemma");

		case CSwordModuleInfo::hebrewPoints:
		return QString("HebrewPoints");

		case CSwordModuleInfo::hebrewCantillation:
		return QString("Cantillation");

		case CSwordModuleInfo::greekAccents:
		return QString("GreekAccents");

		case CSwordModuleInfo::redLetterWords:
		return QString("RedLetterWords");

		case CSwordModuleInfo::textualVariants:
		return QString("Variants");

		case CSwordModuleInfo::scriptureReferences:
		return QString("Scripref");

		case CSwordModuleInfo::morphSegmentation:
		return QString("MorphSegmentation");

		default:
		return QString::null;
	}

	return QString::null;
}

const QString CSwordBackend::booknameLanguage( const QString& language ) {
	if (!language.isEmpty()) {
		sword::LocaleMgr::getSystemLocaleMgr()->setDefaultLocaleName( language.latin1() );

		//refresh the locale of all Bible and commentary modules!
		const ListCSwordModuleInfo::iterator end_it = m_moduleList.end();

		//use what sword returns, language may be different
		QString newLocaleName( sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName()  );

		for (ListCSwordModuleInfo::iterator it = m_moduleList.begin(); it != end_it; ++it) {
			if ( ((*it)->type() == CSwordModuleInfo::Bible) || ((*it)->type() == CSwordModuleInfo::Commentary) ) {
				//Create a new key, it will get the default bookname language
				((sword::VerseKey*)((*it)->module()->getKey()))->setLocale( newLocaleName.latin1() );
			}
		}

	}

	return QString( sword::LocaleMgr::getSystemLocaleMgr()->getDefaultLocaleName() );
}


/** Reload all Sword modules. */
void CSwordBackend::reloadModules() {
	shutdownModules();

	//delete Sword's config to make Sword reload it!

	if (myconfig) { // force reload on config object because we may have changed the paths
		delete myconfig;
		config = myconfig = 0;
		loadConfigDir(configPath);
	}
	else if (config) {
		config->Load();
	}

	initModules();
}

const QStringList CSwordBackend::swordDirList() {
	QStringList ret;
	const QString home = QString(getenv("HOME"));

	//return a list of used Sword dirs. Useful for the installer
	QString configPath = QString("%1/.sword/sword.conf").arg(home);

	if (!QFile(configPath).exists()) {
		configPath = globalConfPath; //e.g. /etc/sword.conf, /usr/local/etc/sword.conf


	}


	QStringList configs = QStringList::split(":", configPath);

	/*ToDo: Use the const iterator as soon as we switch to Qt > 3.1
	  for (QStringList::const_iterator it = configs.constBegin(); it != configs.constEnd(); ++it) {*/

	for (QStringList::const_iterator it = configs.begin(); it != configs.end(); ++it) {
		if (!QFileInfo(*it).exists()) {
			continue;
		}

		//get all DataPath and AugmentPath entries from the config file and add them to the list
		sword::SWConfig conf( (*it).latin1() );

		ret << conf["Install"]["DataPath"].c_str();

		sword::ConfigEntMap group = conf["Install"];

		sword::ConfigEntMap::iterator start = group.equal_range("AugmentPath").first;

		sword::ConfigEntMap::iterator end = group.equal_range("AugmentPath").second;

		for (sword::ConfigEntMap::const_iterator it = start; it != end; ++it) {
			ret << it->second.c_str(); //added augment path
		}
	}

	if (!home.isEmpty()) {
		ret << home + "/.sword/";
	}

	return ret;
}

void CSwordBackend::filterInit() {
	//  qWarning("## INIT");

	SWOptionFilter* tmpFilter = new OSISMorphSegmentation();
	optionFilters.insert(OptionFilterMap::value_type("OSISMorphSegmentation", tmpFilter));
	cleanupFilters.push_back(tmpFilter);
	
	//HACK: replace Sword's ThML strip filter with our own version
	//remove this hack as soon as Sword is fixed
	cleanupFilters.remove(thmlplain);
	delete thmlplain;
	thmlplain = new BT_ThMLPlain();
	cleanupFilters.push_back(thmlplain);
}