The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
diathekemgr.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  *
3  * diathekemgr.cpp - DiathekeMgr
4  *
5  * $Id: diathekemgr.cpp 3504 2017-11-01 10:36:18Z scribe $
6  *
7  * Copyright 2001-2013 CrossWire Bible Society (http://www.crosswire.org)
8  * CrossWire Bible Society
9  * P. O. Box 2528
10  * Tempe, AZ 85280-2528
11  *
12  * This program is free software; you can redistribute it and/or modify it
13  * under the terms of the GNU General Public License as published by the
14  * Free Software Foundation version 2.
15  *
16  * This program is distributed in the hope that it will be useful, but
17  * WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * General Public License for more details.
20  *
21  */
22 
23 //---------------------------------------------------------------------------
24 #include <swmodule.h>
25 
26 #ifdef _ICU_
27 #include <utf8arshaping.h>
28 #include <utf8bidireorder.h>
29 #include <utf8transliterator.h>
30 #endif
31 
32 #ifdef WIN32
33 #include <windows.h>
34 #endif
35 
36 #include "diathekemgr.h"
37 
38 //---------------------------------------------------------------------------
39 DiathekeMgr::DiathekeMgr (SWConfig * iconfig, SWConfig * isysconfig, bool autoload, char enc, char mark, bool ibidi, bool ishape)
40  : SWMgr(iconfig, isysconfig, autoload, new DiathekeFilterMgr(mark, enc))
41 {
42  bidi = ibidi;
43  shape = ishape;
44 
45 #ifdef _ICU_
46  arshaping = new UTF8arShaping();
49 #endif
50  load();
51 
52 #ifdef WIN32
53  OSVERSIONINFO osvi;
54  memset (&osvi, 0, sizeof(OSVERSIONINFO));
55  osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
56  GetVersionEx(&osvi);
57  platformID = osvi.dwPlatformId;
58 #endif
59 
60 }
61 
62 
64 {
65 #ifdef _ICU_
66  if (arshaping)
67  delete arshaping;
68  if (bidireorder)
69  delete bidireorder;
70  if (transliterator)
71  delete transliterator;
72 #endif
73 }
74 
75 
77 {
78  SWBuf lang;
79  ConfigEntMap::iterator entry;
80 
81  lang = ((entry = section.find("Lang")) != section.end()) ? (*entry).second : (SWBuf)"en";
82 
83 #ifdef _ICU_
84  bool rtl;
85  rtl = ((entry = section.find("Direction")) != section.end()) ? ((*entry).second == "RtoL") : false;
86 
87  if (shape) {
88  module->addRenderFilter(arshaping);
89  }
90  if (bidi && rtl) {
91  module->addRenderFilter(bidireorder);
92  }
93 #endif
94  SWMgr::addRenderFilters(module, section);
95 }
96 
97 signed char DiathekeMgr::load() {
98  signed char retval = SWMgr::load();
99 #ifdef _ICU_
100  optionFilters["UTF8Transliterator"] = transliterator;
101  options.push_back(transliterator->getOptionName());
102 #endif
103  return retval;
104 };
105 
107 
108  SWMgr::addGlobalOptionFilters(module, section);
109 #ifdef _ICU_
110  module->addOptionFilter(transliterator);
111 #endif
112 };
113 
virtual const char * getOptionName()
Definition: swoptfilter.h:72
virtual signed char load()
Definition: swmgr.cpp:837
SWText * module
Definition: osis2mod.cpp:105
SWFilter * bidireorder
Definition: diathekemgr.h:33
virtual signed char load()
Definition: diathekemgr.cpp:97
virtual ~DiathekeMgr()
Definition: diathekemgr.cpp:63
SWFilter * arshaping
Definition: diathekemgr.h:32
virtual void addRenderFilters(SWModule *module, ConfigEntMap &section)
Definition: swmgr.cpp:1272
DiathekeMgr(SWConfig *iconf=NULL, SWConfig *isysconfig=NULL, bool autoload=false, char enc=ENC_UTF8, char mark=FMT_PLAIN, bool bidi=false, bool shape=false)
Definition: diathekemgr.cpp:39
SWOptionFilter * transliterator
Definition: diathekemgr.h:34
SWORD_NAMESPACE_START typedef multimapwithdefault< SWBuf, SWBuf, std::less< SWBuf > > ConfigEntMap
Definition: swconfig.h:35
virtual void addRenderFilters(SWModule *module, ConfigEntMap &section)
Definition: diathekemgr.cpp:76
virtual void addGlobalOptionFilters(SWModule *module, ConfigEntMap &section)
Definition: swmgr.cpp:1140
virtual void addGlobalOptionFilters(SWModule *module, ConfigEntMap &section)