The SWORD Project  1.9.0.svnversion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DiathekeFilterMgr Class Reference

#include <diafiltmgr.h>

+ Inheritance diagram for DiathekeFilterMgr:
+ Collaboration diagram for DiathekeFilterMgr:

Public Member Functions

virtual void addEncodingFilters (SWModule *module, ConfigEntMap &section)
 
virtual void addGlobalOptions (SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end)
 
virtual void addLocalOptions (SWModule *module, ConfigEntMap &section, ConfigEntMap::iterator start, ConfigEntMap::iterator end)
 
virtual void addRawFilters (SWModule *module, ConfigEntMap &section)
 
virtual void addRenderFilters (SWModule *module, ConfigEntMap &section)
 
virtual void addStripFilters (SWModule *module, ConfigEntMap &section)
 
 DiathekeFilterMgr (char markup=FMT_THML, char encoding=ENC_UTF8)
 
char Encoding (char enc)
 
char getEncoding () const
 
virtual SWMgrgetParentMgr ()
 
char Markup (char m=FMT_UNKNOWN)
 
void setEncoding (char enc)
 
virtual void setParentMgr (SWMgr *parentMgr)
 
 ~DiathekeFilterMgr ()
 

Protected Member Functions

void CreateFilters (char markup)
 

Protected Attributes

char encoding
 
SWFilterfromgbf
 
SWFilterfromosis
 
SWFilterfromplain
 
SWFilterfromtei
 
SWFilterfromthml
 
SWFilterlatin1utf8
 
char markup
 
SWFilterscsuutf8
 
SWFiltertargetenc
 
SWFilterutf16utf8
 

Detailed Description

Definition at line 35 of file diafiltmgr.h.

Constructor & Destructor Documentation

DiathekeFilterMgr::DiathekeFilterMgr ( char  markup = FMT_THML,
char  encoding = ENC_UTF8 
)

Definition at line 65 of file diafiltmgr.cpp.

66  : EncodingFilterMgr(enc) {
67 
68  markup = mark;
69 
71 }
void CreateFilters(char markup)
Definition: diafiltmgr.cpp:219
EncodingFilterMgr(char encoding=ENC_UTF8)
Definition: encfiltmgr.cpp:55
DiathekeFilterMgr::~DiathekeFilterMgr ( )

Definition at line 73 of file diafiltmgr.cpp.

73  {
74  if (fromthml)
75  delete (fromthml);
76  if (fromgbf)
77  delete (fromgbf);
78  if (fromplain)
79  delete (fromplain);
80  if (fromosis)
81  delete (fromosis);
82  if (fromtei)
83  delete (fromtei);
84 }
SWFilter * fromgbf
Definition: diafiltmgr.h:38
SWFilter * fromplain
Definition: diafiltmgr.h:39
SWFilter * fromosis
Definition: diafiltmgr.h:40
SWFilter * fromthml
Definition: diafiltmgr.h:37
SWFilter * fromtei
Definition: diafiltmgr.h:41

Member Function Documentation

void EncodingFilterMgr::addEncodingFilters ( SWModule module,
ConfigEntMap section 
)
virtualinherited

Adds the encoding filters which are defined in "section" to the SWModule object "module".

Parameters
moduleTo this module the encoding filter(s) are added
sectionWe use this section to get a list of filters we should apply to the module

Reimplemented from SWFilterMgr.

Definition at line 106 of file encfiltmgr.cpp.

106  {
107  if (targetenc)
108  module->addEncodingFilter(targetenc);
109 }
virtual SWModule & addEncodingFilter(SWFilter *newFilter)
Definition: swmodule.h:627
SWFilter * targetenc
Definition: encfiltmgr.h:46
void SWFilterMgr::addGlobalOptions ( SWModule module,
ConfigEntMap section,
ConfigEntMap::iterator  start,
ConfigEntMap::iterator  end 
)
virtualinherited

Definition at line 48 of file swfiltermgr.cpp.

48  {
49 }
void SWFilterMgr::addLocalOptions ( SWModule module,
ConfigEntMap section,
ConfigEntMap::iterator  start,
ConfigEntMap::iterator  end 
)
virtualinherited

Definition at line 52 of file swfiltermgr.cpp.

52  {
53 }
void EncodingFilterMgr::addRawFilters ( SWModule module,
ConfigEntMap section 
)
virtualinherited

Adds the raw filters which are defined in "section" to the SWModule object "module".

Parameters
moduleTo this module the raw filter(s) are added
sectionWe use this section to get a list of filters we should apply to the module

Reimplemented from SWFilterMgr.

Definition at line 89 of file encfiltmgr.cpp.

89  {
90 
91  ConfigEntMap::iterator entry;
92 
93  SWBuf encoding = ((entry = section.find("Encoding")) != section.end()) ? (*entry).second : (SWBuf)"";
94  if (!encoding.length() || !stricmp(encoding.c_str(), "Latin-1")) {
95  module->addRawFilter(latin1utf8);
96  }
97  else if (!stricmp(encoding.c_str(), "SCSU")) {
98  module->addRawFilter(scsuutf8);
99  }
100  else if (!stricmp(encoding.c_str(), "UTF-16")) {
101  module->addRawFilter(utf16utf8);
102  }
103 }
SWFilter * utf16utf8
Definition: encfiltmgr.h:45
Definition: swbuf.h:47
unsigned long length() const
Definition: swbuf.h:197
int stricmp(const char *s1, const char *s2)
Definition: utilstr.cpp:194
const char * c_str() const
Definition: swbuf.h:158
SWFilter * latin1utf8
Definition: encfiltmgr.h:43
virtual SWModule & addRawFilter(SWFilter *newFilter)
Definition: swmodule.h:694
SWFilter * scsuutf8
Definition: encfiltmgr.h:44
void DiathekeFilterMgr::addRenderFilters ( SWModule module,
ConfigEntMap section 
)
virtual

Adds the render filters which are defined in "section" to the SWModule object "module".

Parameters
moduleTo this module the render filter(s) are added
sectionWe use this section to get a list of filters we should apply to the module

Reimplemented from SWFilterMgr.

Definition at line 86 of file diafiltmgr.cpp.

86  {
87  switch (module->getMarkup()) {
88  case FMT_THML:
89  if (fromthml)
91  break;
92  case FMT_GBF:
93  if (fromgbf)
95  break;
96  case FMT_PLAIN:
97  if (fromplain)
99  break;
100  case FMT_OSIS:
101  if (fromosis)
103  break;
104  case FMT_TEI:
105  if (fromtei)
107  break;
108  }
110 }
SWFilter * fromgbf
Definition: diafiltmgr.h:38
virtual SWModule & addRenderFilter(SWFilter *newFilter)
Definition: swmodule.h:564
SWText * module
Definition: osis2mod.cpp:105
char getMarkup() const
Definition: swmodule.h:427
SWFilter * fromplain
Definition: diafiltmgr.h:39
SWFilter * fromosis
Definition: diafiltmgr.h:40
virtual void addRenderFilters(SWModule *module, ConfigEntMap &section)
Definition: swfiltermgr.cpp:72
SWFilter * fromthml
Definition: diafiltmgr.h:37
SWFilter * fromtei
Definition: diafiltmgr.h:41
void SWFilterMgr::addStripFilters ( SWModule module,
ConfigEntMap section 
)
virtualinherited

Adds the strip filters which are defined in "section" to the SWModule object "module".

Parameters
moduleTo this module the strip filter(s) are added
sectionWe use this section to get a list of filters we should apply to the module

Definition at line 82 of file swfiltermgr.cpp.

82  {
83 }
void DiathekeFilterMgr::CreateFilters ( char  markup)
protected

Definition at line 219 of file diafiltmgr.cpp.

219  {
220 
221  switch (markup) {
222  case FMT_INTERNAL:
223  fromplain = NULL;
224  fromthml = NULL;
225  fromgbf = NULL;
226  fromosis = NULL;
227  fromtei = NULL;
228  break;
229 
230  case FMT_CGI:
231  fromplain = NULL;
232  fromthml = new ThMLCGI();
233  fromgbf = new GBFCGI();
234  fromosis = new OSISCGI();
235  fromtei = NULL; // TODO: write TEICGI()
236  break;
237 
238  case FMT_PLAIN:
239  fromplain = NULL;
240  fromthml = new ThMLPlain();
241  fromgbf = new GBFPlain();
242  fromosis = new OSISPlain();
243  fromtei = new TEIPlain();
244  break;
245 
246  case FMT_THML:
247  fromplain = NULL;
248  fromthml = NULL;
249  fromgbf = new GBFThML();
250  fromosis = NULL;
251  fromtei = NULL;
252  break;
253 
254  case FMT_GBF:
255  fromplain = NULL;
256  fromthml = new ThMLGBF();
257  fromgbf = NULL;
258  fromosis = NULL;
259  fromtei = NULL;
260  break;
261 
262  case FMT_HTML:
263  fromplain = NULL;
264  fromthml = new ThMLHTML();
265  fromgbf = new GBFHTML();
266  fromosis = NULL;
267  fromtei = NULL;
268  break;
269 
270  case FMT_HTMLHREF:
271  fromplain = NULL;
272  fromthml = new ThMLHTMLHREF();
273  fromgbf = new GBFHTMLHREF();
274  fromosis = new OSISHTMLHREF();
275  fromtei = new TEIHTMLHREF();
276  break;
277 
278  case FMT_RTF:
279  fromplain = NULL;
280  fromthml = new ThMLRTF();
281  fromgbf = new GBFRTF();
282  fromosis = new OSISRTF();
283  fromtei = new TEIRTF();
284  break;
285 
286  case FMT_LATEX:
287  fromplain = NULL;
288  fromthml = new ThMLLaTeX();
289  fromgbf = new GBFLaTeX();
290  fromosis = new OSISLaTeX();
291  fromtei = new TEILaTeX();
292  break;
293 
294  case FMT_OSIS:
295  fromplain = NULL;
296  fromthml = new ThMLOSIS();
297  fromgbf = new GBFOSIS();
298  fromosis = new OSISOSIS();
299  fromtei = NULL;
300  break;
301 
302  case FMT_WEBIF:
303  fromplain = NULL;
304  fromthml = new ThMLWEBIF();
305  fromgbf = new GBFWEBIF();
306  fromosis = new OSISWEBIF();
307  fromtei = NULL;
308  break;
309 
310  case FMT_TEI:
311  fromplain = NULL;
312  fromthml = NULL;
313  fromgbf = NULL;
314  fromosis = NULL;
315  fromtei = NULL;
316  break;
317 
318  case FMT_XHTML:
319  fromplain = NULL;
320  fromthml = new ThMLXHTML();
321  fromgbf = new GBFXHTML();
322  fromosis = new OSISXHTML();
323  fromtei = new TEIXHTML();
324  break;
325  }
326 
327 }
Definition: gbfrtf.h:33
Definition: gbfcgi.h:33
#define FMT_INTERNAL
Definition: diafiltmgr.h:27
SWFilter * fromgbf
Definition: diafiltmgr.h:38
SWFilter * fromplain
Definition: diafiltmgr.h:39
SWFilter * fromosis
Definition: diafiltmgr.h:40
Definition: teirtf.h:33
return NULL
Definition: regex.c:7953
#define FMT_CGI
Definition: diafiltmgr.h:26
SWFilter * fromthml
Definition: diafiltmgr.h:37
SWFilter * fromtei
Definition: diafiltmgr.h:41
char EncodingFilterMgr::Encoding ( char  enc)
inlineinherited

Encoding sets/gets the encoding after initialization

DEPRECATED: use setEncoding / getEncoding

Returns
The current encoding format.

Definition at line 75 of file encfiltmgr.h.

75 { if (enc != ENC_UNKNOWN) setEncoding(enc); return getEncoding(); }
char getEncoding() const
Definition: encfiltmgr.h:81
void setEncoding(char enc)
Definition: encfiltmgr.cpp:119
char EncodingFilterMgr::getEncoding ( ) const
inlineinherited

getEncoding gets the encoding after initialization

Returns
The current encoding format.

Definition at line 81 of file encfiltmgr.h.

81 { return encoding; }
SWMgr * SWFilterMgr::getParentMgr ( )
virtualinherited

Definition at line 43 of file swfiltermgr.cpp.

43  {
44  return parentMgr;
45 }
SWMgr * parentMgr
Definition: swfiltermgr.h:39
char DiathekeFilterMgr::Markup ( char  m = FMT_UNKNOWN)

Definition at line 113 of file diafiltmgr.cpp.

113  {
114  if (mark && mark != markup) {
115  markup = mark;
116  ModMap::const_iterator module;
117 
118  SWFilter * oldplain = fromplain;
119  SWFilter * oldthml = fromthml;
120  SWFilter * oldgbf = fromgbf;
121  SWFilter * oldosis = fromosis;
122  SWFilter * oldtei = fromtei;
123 
125 
126  for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
127  switch (module->second->getMarkup()) {
128  case FMT_THML:
129  if (oldthml != fromthml) {
130  if (oldthml) {
131  if (!fromthml) {
132  module->second->removeRenderFilter(oldthml);
133  }
134  else {
135  module->second->replaceRenderFilter(oldthml, fromthml);
136  }
137  }
138  else if (fromthml) {
139  module->second->addRenderFilter(fromthml);
140  }
141  }
142  break;
143  case FMT_GBF:
144  if (oldgbf != fromgbf) {
145  if (oldgbf) {
146  if (!fromgbf) {
147  module->second->removeRenderFilter(oldgbf);
148  }
149  else {
150  module->second->replaceRenderFilter(oldgbf, fromgbf);
151  }
152  }
153  else if (fromgbf) {
154  module->second->addRenderFilter(fromgbf);
155  }
156  break;
157  }
158  case FMT_PLAIN:
159  if (oldplain != fromplain) {
160  if (oldplain) {
161  if (!fromplain) {
162  module->second->removeRenderFilter(oldplain);
163  }
164  else {
165  module->second->replaceRenderFilter(oldplain, fromplain);
166  }
167  }
168  else if (fromplain) {
169  module->second->addRenderFilter(fromplain);
170  }
171  break;
172  }
173  case FMT_OSIS:
174  if (oldosis != fromosis) {
175  if (oldosis) {
176  if (!fromosis) {
177  module->second->removeRenderFilter(oldosis);
178  }
179  else {
180  module->second->replaceRenderFilter(oldosis, fromosis);
181  }
182  }
183  else if (fromosis) {
184  module->second->addRenderFilter(fromosis);
185  }
186  break;
187  }
188  case FMT_TEI:
189  if (oldtei != fromtei) {
190  if (oldtei) {
191  if (!fromtei) {
192  module->second->removeRenderFilter(oldtei);
193  }
194  else {
195  module->second->replaceRenderFilter(oldtei, fromtei);
196  }
197  }
198  else if (fromtei) {
199  module->second->addRenderFilter(fromtei);
200  }
201  break;
202  }
203  }
204 
205  if (oldthml)
206  delete oldthml;
207  if (oldgbf)
208  delete oldgbf;
209  if (oldplain)
210  delete oldplain;
211  if (oldosis)
212  delete oldosis;
213  if (oldtei)
214  delete oldtei;
215  }
216  return markup;
217 }
void CreateFilters(char markup)
Definition: diafiltmgr.cpp:219
SWFilter * fromgbf
Definition: diafiltmgr.h:38
SWText * module
Definition: osis2mod.cpp:105
SWFilter * fromplain
Definition: diafiltmgr.h:39
SWFilter * fromosis
Definition: diafiltmgr.h:40
virtual SWMgr * getParentMgr()
Definition: swfiltermgr.cpp:43
SWFilter * fromthml
Definition: diafiltmgr.h:37
SWFilter * fromtei
Definition: diafiltmgr.h:41
void EncodingFilterMgr::setEncoding ( char  enc)
inherited

setEncoding sets the encoding after initialization

Parameters
encThe new encoding or ENC_UNKNOWN if you just want to get the current markup.

Definition at line 119 of file encfiltmgr.cpp.

119  {
120  if (enc && enc != encoding) {
121  encoding = enc;
122  SWFilter *oldfilter = targetenc;
123 
124  switch (encoding) {
125  case ENC_LATIN1: targetenc = new UTF8Latin1(); break;
126  case ENC_UTF16: targetenc = new UTF8UTF16(); break;
127  case ENC_RTF: targetenc = new UnicodeRTF(); break;
128  case ENC_HTML: targetenc = new UTF8HTML(); break;
129 #ifdef _ICU_
130  case ENC_SCSU: targetenc = new UTF8SCSU(); break;
131 #endif
132  default: // i.e. case ENC_UTF8
133  targetenc = NULL;
134  }
135 
136  ModMap::const_iterator module;
137 
138  if (oldfilter != targetenc) {
139  if (oldfilter) {
140  if (!targetenc) {
141  for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
142  module->second->removeRenderFilter(oldfilter);
143  }
144  else {
145  for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
146  module->second->replaceRenderFilter(oldfilter, targetenc);
147  }
148  delete oldfilter;
149  }
150  else if (targetenc) {
151  for (module = getParentMgr()->Modules.begin(); module != getParentMgr()->Modules.end(); module++)
152  module->second->addRenderFilter(targetenc);
153  }
154  }
155  }
156 }
ModMap Modules
Definition: swmgr.h:322
SWText * module
Definition: osis2mod.cpp:105
SWFilter * targetenc
Definition: encfiltmgr.h:46
return NULL
Definition: regex.c:7953
virtual SWModule & removeRenderFilter(SWFilter *oldFilter)
Definition: swmodule.h:585
virtual SWMgr * getParentMgr()
Definition: swfiltermgr.cpp:43
virtual SWModule & replaceRenderFilter(SWFilter *oldFilter, SWFilter *newFilter)
Definition: swmodule.h:599
void SWFilterMgr::setParentMgr ( SWMgr parentMgr)
virtualinherited

Definition at line 38 of file swfiltermgr.cpp.

38  {
39  this->parentMgr = parentMgr;
40 }
SWMgr * parentMgr
Definition: swfiltermgr.h:39

Member Data Documentation

char EncodingFilterMgr::encoding
protectedinherited

Definition at line 52 of file encfiltmgr.h.

SWFilter* DiathekeFilterMgr::fromgbf
protected

Definition at line 38 of file diafiltmgr.h.

SWFilter* DiathekeFilterMgr::fromosis
protected

Definition at line 40 of file diafiltmgr.h.

SWFilter* DiathekeFilterMgr::fromplain
protected

Definition at line 39 of file diafiltmgr.h.

SWFilter* DiathekeFilterMgr::fromtei
protected

Definition at line 41 of file diafiltmgr.h.

SWFilter* DiathekeFilterMgr::fromthml
protected

Definition at line 37 of file diafiltmgr.h.

SWFilter* EncodingFilterMgr::latin1utf8
protectedinherited

Definition at line 43 of file encfiltmgr.h.

char DiathekeFilterMgr::markup
protected

Definition at line 43 of file diafiltmgr.h.

SWFilter* EncodingFilterMgr::scsuutf8
protectedinherited

Definition at line 44 of file encfiltmgr.h.

SWFilter* EncodingFilterMgr::targetenc
protectedinherited

Definition at line 46 of file encfiltmgr.h.

SWFilter* EncodingFilterMgr::utf16utf8
protectedinherited

Definition at line 45 of file encfiltmgr.h.


The documentation for this class was generated from the following files: