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

#include <teihtmlhref.h>

+ Inheritance diagram for TEIHTMLHREF:
+ Collaboration diagram for TEIHTMLHREF:

Classes

class  MyUserData
 

Public Member Functions

virtual const char * getHeader () const
 
virtual char processText (SWBuf &text, const SWKey *key=0, const SWModule *module=0)
 
void setRenderNoteNumbers (bool val=true)
 
 TEIHTMLHREF ()
 

Protected Member Functions

void addAllowedEscapeString (const char *findString)
 
void addEscapeStringSubstitute (const char *findString, const char *replaceString)
 
void addTokenSubstitute (const char *findString, const char *replaceString)
 
void appendEscapeString (SWBuf &buf, const char *escString)
 
virtual BasicFilterUserDatacreateUserData (const SWModule *module, const SWKey *key)
 
virtual bool handleEscapeString (SWBuf &buf, const char *escString, BasicFilterUserData *userData)
 
virtual bool handleNumericEscapeString (SWBuf &buf, const char *escString)
 
virtual bool handleToken (SWBuf &buf, const char *token, BasicFilterUserData *userData)
 
bool passAllowedEscapeString (SWBuf &buf, const char *escString)
 
virtual bool processStage (char, SWBuf &, char *&, BasicFilterUserData *)
 
void removeAllowedEscapeString (const char *findString)
 
void removeEscapeStringSubstitute (const char *findString)
 
void removeTokenSubstitute (const char *findString)
 
void setEscapeEnd (const char *escEnd)
 
void setEscapeStart (const char *escStart)
 
void setEscapeStringCaseSensitive (bool val)
 
void setPassThruNumericEscapeString (bool val)
 
void setPassThruUnknownEscapeString (bool val)
 
void setPassThruUnknownToken (bool val)
 
virtual void setStageProcessing (char stages)
 
void setTokenCaseSensitive (bool val)
 
void setTokenEnd (const char *tokenEnd)
 
void setTokenStart (const char *tokenStart)
 
bool substituteEscapeString (SWBuf &buf, const char *escString)
 
bool substituteToken (SWBuf &buf, const char *token)
 

Static Protected Attributes

static const char FINALIZE = 8
 
static const char INITIALIZE = 1
 
static const char POSTCHAR = 4
 
static const char PRECHAR = 2
 

Private Attributes

bool renderNoteNumbers
 

Detailed Description

this filter converts TEI text to HTMLHREF text

Definition at line 33 of file teihtmlhref.h.

Constructor & Destructor Documentation

TEIHTMLHREF::TEIHTMLHREF ( )

Definition at line 44 of file teihtmlhref.cpp.

44  {
45  setTokenStart("<");
46  setTokenEnd(">");
47 
48  setEscapeStart("&");
49  setEscapeEnd(";");
50 
52 
53  addAllowedEscapeString("quot");
54  addAllowedEscapeString("apos");
58 
60 
61  renderNoteNumbers = false;
62 }
void setTokenEnd(const char *tokenEnd)
void addAllowedEscapeString(const char *findString)
void setTokenCaseSensitive(bool val)
void setEscapeStart(const char *escStart)
void setTokenStart(const char *tokenStart)
void setEscapeStringCaseSensitive(bool val)
void setEscapeEnd(const char *escEnd)
bool renderNoteNumbers
Definition: teihtmlhref.h:36

Member Function Documentation

void SWBasicFilter::addAllowedEscapeString ( const char *  findString)
protectedinherited

Registers an esc control sequence that can pass unchanged

Definition at line 156 of file swbasicfilter.cpp.

156  {
157  char *buf = 0;
158 
159  if (!escStringCaseSensitive) {
160  stdstr(&buf, findString);
161  toupperstr(buf);
162  p->escPassSet.insert(StringSet::value_type(buf));
163  delete [] buf;
164  }
165  else p->escPassSet.insert(StringSet::value_type(findString));
166 }
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
bool escStringCaseSensitive
Definition: swbasicfilter.h:74
char * toupperstr(char *t, unsigned int max=0)
Definition: stringmgr.h:107
Private * p
Definition: swbasicfilter.h:82
void SWBasicFilter::addEscapeStringSubstitute ( const char *  findString,
const char *  replaceString 
)
protectedinherited

Registers an esc control sequence

Definition at line 176 of file swbasicfilter.cpp.

176  {
177  char *buf = 0;
178 
179  if (!escStringCaseSensitive) {
180  stdstr(&buf, findString);
181  toupperstr(buf);
182  p->escSubMap.insert(DualStringMap::value_type(buf, replaceString));
183  delete [] buf;
184  }
185  else p->escSubMap.insert(DualStringMap::value_type(findString, replaceString));
186 }
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
bool escStringCaseSensitive
Definition: swbasicfilter.h:74
char * toupperstr(char *t, unsigned int max=0)
Definition: stringmgr.h:107
Private * p
Definition: swbasicfilter.h:82
void SWBasicFilter::addTokenSubstitute ( const char *  findString,
const char *  replaceString 
)
protectedinherited

Registers a simple token substitutions. Usually called from the c-tor of a subclass

Definition at line 136 of file swbasicfilter.cpp.

136  {
137  char *buf = 0;
138 
139  if (!tokenCaseSensitive) {
140  stdstr(&buf, findString);
141  toupperstr(buf);
142  p->tokenSubMap[buf] = replaceString;
143  delete [] buf;
144  }
145  else p->tokenSubMap[findString] = replaceString;
146 }
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
bool tokenCaseSensitive
Definition: swbasicfilter.h:75
DualStringMap tokenSubMap
char * toupperstr(char *t, unsigned int max=0)
Definition: stringmgr.h:107
Private * p
Definition: swbasicfilter.h:82
void SWBasicFilter::appendEscapeString ( SWBuf buf,
const char *  escString 
)
protectedinherited

This appends escString to buf as an entity

Definition at line 216 of file swbasicfilter.cpp.

216  {
217  buf += escStart;
218  buf += escString;
219  buf += escEnd;
220 }
virtual BasicFilterUserData* TEIHTMLHREF::createUserData ( const SWModule module,
const SWKey key 
)
inlineprotectedvirtual

Reimplemented from SWBasicFilter.

Definition at line 47 of file teihtmlhref.h.

47  {
48  return new MyUserData(module, key);
49  }
virtual const char* SWFilter::getHeader ( ) const
inlinevirtualinherited

This method can supply a header associated with the processing done with this filter. A typical example is a suggested CSS style block for classed containers.

Reimplemented in OSISLaTeX, OSISXHTML, ThMLLaTeX, ThMLXHTML, TEIXHTML, GBFLaTeX, and GBFXHTML.

Definition at line 62 of file swfilter.h.

62 { return ""; }
bool SWBasicFilter::handleEscapeString ( SWBuf buf,
const char *  escString,
BasicFilterUserData userData 
)
protectedvirtualinherited

This function is called for every escape sequence encountered in the input text.

Parameters
bufthe output buffer
escStringthe escape sequence (e.g. "amp" for &amp;)
userDatauser storage space for data transient to 1 full buffer parse
Returns
false if was not handled and should be handled in
subclasses should return true if they handled the esc seq, or false if they did not.

Definition at line 286 of file swbasicfilter.cpp.

286  {
287  return substituteEscapeString(buf, escString);
288 }
bool substituteEscapeString(SWBuf &buf, const char *escString)
bool SWBasicFilter::handleNumericEscapeString ( SWBuf buf,
const char *  escString 
)
protectedvirtualinherited

This function is called for all numeric escape sequences. If passThrough

Parameters
bufthe output buffer
escStringthe escape sequence (e.g. "#235" for &235;)
Returns
subclasses should return true if they handled the esc seq, or false if they did not.

Definition at line 244 of file swbasicfilter.cpp.

244  {
245  if (passThruNumericEsc) {
246  appendEscapeString(buf, escString);
247  return true;
248  }
249  return false;
250 }
bool passThruNumericEsc
Definition: swbasicfilter.h:78
void appendEscapeString(SWBuf &buf, const char *escString)
bool TEIHTMLHREF::handleToken ( SWBuf buf,
const char *  token,
BasicFilterUserData userData 
)
protectedvirtual

This function is called for every token encountered in the input text.

Parameters
bufthe output buffer
tokenthe token (e.g. "p align='left'"
userDatauser storage space for data transient to 1 full buffer parse
Returns
subclasses should return true if they handled the token, or false if they did not.

Reimplemented from SWBasicFilter.

Definition at line 64 of file teihtmlhref.cpp.

64  {
65  // manually process if it wasn't a simple substitution
66  if (!substituteToken(buf, token)) {
67  MyUserData *u = (MyUserData *)userData;
68  XMLTag tag(token);
69 
70  if (!strcmp(tag.getName(), "p")) {
71  if ((!tag.isEndTag()) && (!tag.isEmpty())) { // non-empty start tag
72  buf += "<!P><br />";
73  }
74  else if (tag.isEndTag()) { // end tag
75  buf += "<!/P><br />";
76  //userData->supressAdjacentWhitespace = true;
77  }
78  else { // empty paragraph break marker
79  buf += "<!P><br />";
80  //userData->supressAdjacentWhitespace = true;
81  }
82  }
83 
84  // <hi>
85  else if (!strcmp(tag.getName(), "hi")) {
86  if ((!tag.isEndTag()) && (!tag.isEmpty())) {
87  SWBuf rend = tag.getAttribute("rend");
88 
89  u->lastHi = rend;
90  if (rend == "italic" || rend == "ital")
91  buf += "<i>";
92  else if (rend == "bold")
93  buf += "<b>";
94  else if (rend == "super" || rend == "sup")
95  buf += "<sup>";
96  else if (rend == "sub")
97  buf += "<sub>";
98  else if (rend == "overline")
99  buf += "<span style=\"text-decoration:overline\">";
100  }
101  else if (tag.isEndTag()) {
102  SWBuf rend = u->lastHi;
103  if (rend == "italic" || rend == "ital")
104  buf += "</i>";
105  else if (rend == "bold")
106  buf += "</b>";
107  else if (rend == "super" || rend == "sup")
108  buf += "</sup>";
109  else if (rend == "sub")
110  buf += "</sub>";
111  else if (rend == "overline")
112  buf += "</span>";
113  }
114  }
115 
116  // <entryFree>
117  else if (!strcmp(tag.getName(), "entryFree")) {
118  if ((!tag.isEndTag()) && (!tag.isEmpty())) {
119  SWBuf n = tag.getAttribute("n");
120  if (n != "") {
121  buf += "<b>";
122  buf += n;
123  buf += "</b>";
124  }
125  }
126  }
127 
128  // <sense>
129  else if (!strcmp(tag.getName(), "sense")) {
130  if ((!tag.isEndTag()) && (!tag.isEmpty())) {
131  SWBuf n = tag.getAttribute("n");
132  if (n != "") {
133  buf += "<br /><b>";
134  buf += n;
135  buf += "</b> ";
136  }
137  }
138  }
139 
140  // <div>
141  else if (!strcmp(tag.getName(), "div")) {
142 
143  if ((!tag.isEndTag()) && (!tag.isEmpty())) {
144  buf += "<!P>";
145  }
146  else if (tag.isEndTag()) {
147  }
148  }
149 
150  // <lb.../>
151  else if (!strcmp(tag.getName(), "lb")) {
152  buf += "<br />";
153  }
154 
155  // <pos>, <gen>, <case>, <gram>, <number>, <mood>, <pron>, <def>
156  else if (!strcmp(tag.getName(), "pos") ||
157  !strcmp(tag.getName(), "gen") ||
158  !strcmp(tag.getName(), "case") ||
159  !strcmp(tag.getName(), "gram") ||
160  !strcmp(tag.getName(), "number") ||
161  !strcmp(tag.getName(), "pron") /*||
162  !strcmp(tag.getName(), "def")*/) {
163  if ((!tag.isEndTag()) && (!tag.isEmpty())) {
164  buf += "<i>";
165  }
166  else if (tag.isEndTag()) {
167  buf += "</i>";
168  }
169  }
170 
171  // <tr>
172  else if (!strcmp(tag.getName(), "tr")) {
173  if ((!tag.isEndTag()) && (!tag.isEmpty())) {
174  buf += "<i>";
175  }
176  else if (tag.isEndTag()) {
177  buf += "</i>";
178  }
179  }
180 
181  // orth
182  else if (!strcmp(tag.getName(), "orth")) {
183  if ((!tag.isEndTag()) && (!tag.isEmpty())) {
184  buf += "<b>";
185  }
186  else if (tag.isEndTag()) {
187  buf += "</b>";
188  }
189  }
190 
191  // <etym>, <usg>
192  else if (!strcmp(tag.getName(), "etym") ||
193  !strcmp(tag.getName(), "usg")) {
194  // do nothing here
195  }
196  else if (!strcmp(tag.getName(), "ref")) {
197  if (!tag.isEndTag()) {
198  u->suspendTextPassThru = true;
199  SWBuf target;
200  SWBuf work;
201  SWBuf ref;
202 
203  int was_osisref = false;
204  if(tag.getAttribute("osisRef"))
205  {
206  target += tag.getAttribute("osisRef");
207  was_osisref=true;
208  }
209  else if(tag.getAttribute("target"))
210  target += tag.getAttribute("target");
211 
212  if(target.size())
213  {
214  const char* the_ref = strchr(target, ':');
215 
216  if(!the_ref) {
217  // No work
218  ref = target;
219  }
220  else {
221  // Compensate for starting :
222  ref = the_ref + 1;
223 
224  int size = (int)(target.size() - ref.size() - 1);
225  work.setSize(size);
226  strncpy(work.getRawData(), target, size);
227  }
228 
229  if(was_osisref)
230  {
231  buf.appendFormatted("<a href=\"passagestudy.jsp?action=showRef&type=scripRef&value=%s&module=%s\">",
232  (ref) ? URL::encode(ref.c_str()).c_str() : "",
233  (work.size()) ? URL::encode(work.c_str()).c_str() : "");
234  }
235  else
236  {
237  // Dictionary link, or something
238  buf.appendFormatted("<a href=\"sword://%s/%s\">",
239  (work.size()) ? URL::encode(work.c_str()).c_str() : u->version.c_str(),
240  (ref) ? URL::encode(ref.c_str()).c_str() : ""
241  );
242  }
243  }
244  else
245  {
246  //std::cout << "TARGET WASN'T\n";
247  }
248 
249  }
250  else {
251  buf += u->lastTextNode.c_str();
252  buf += "</a>";
253 
254  u->suspendTextPassThru = false;
255  }
256  }
257 
258  // <note> tag
259  else if (!strcmp(tag.getName(), "note")) {
260  if (!tag.isEndTag()) {
261  if (!tag.isEmpty()) {
262  u->suspendTextPassThru = true;
263  }
264  }
265  if (tag.isEndTag()) {
266  SWBuf footnoteNumber = tag.getAttribute("swordFootnote");
267  SWBuf noteName = tag.getAttribute("n");
268 
269  buf.appendFormatted("<a href=\"passagestudy.jsp?action=showNote&type=n&value=%s&module=%s&passage=%s\"><small><sup class=\"n\">*n%s</sup></small></a>",
270  URL::encode(footnoteNumber.c_str()).c_str(),
271  URL::encode(u->version.c_str()).c_str(),
272  URL::encode(u->key->getText()).c_str(),
273  (renderNoteNumbers ? URL::encode(noteName.c_str()).c_str() : ""));
274 
275  u->suspendTextPassThru = false;
276  }
277  }
278  // <graphic> image tag
279  else if (!strcmp(tag.getName(), "graphic")) {
280  const char *url = tag.getAttribute("url");
281  if (url) { // assert we have a url attribute
282  SWBuf filepath;
283  if (userData->module) {
284  filepath = userData->module->getConfigEntry("AbsoluteDataPath");
285  if ((filepath.size()) && (filepath[filepath.size()-1] != '/') && (url[0] != '/'))
286  filepath += '/';
287  }
288  filepath += url;
289  // images become clickable, if the UI supports showImage.
290  buf.appendFormatted("<a href=\"passagestudy.jsp?action=showImage&value=%s&module=%s\"><img src=\"file:%s\" border=\"0\" /></a>",
291  URL::encode(filepath.c_str()).c_str(),
292  URL::encode(u->version.c_str()).c_str(),
293  filepath.c_str());
294  u->suspendTextPassThru = true;
295  }
296  }
297  // <table> <row> <cell>
298  else if (!strcmp(tag.getName(), "table")) {
299  if ((!tag.isEndTag()) && (!tag.isEmpty())) {
300  buf += "<table><tbody>\n";
301  }
302  else if (tag.isEndTag()) {
303  buf += "</tbody></table>\n";
304  u->supressAdjacentWhitespace = true;
305  }
306 
307  }
308  else if (!strcmp(tag.getName(), "row")) {
309  if ((!tag.isEndTag()) && (!tag.isEmpty())) {
310  buf += "\t<tr>";
311  }
312  else if (tag.isEndTag()) {
313  buf += "</tr>\n";
314  }
315  }
316  else if (!strcmp(tag.getName(), "cell")) {
317  if ((!tag.isEndTag()) && (!tag.isEmpty())) {
318  buf += "<td>";
319  }
320  else if (tag.isEndTag()) {
321  buf += "</td>";
322  }
323  }
324 
325  // <list> <item>
326  else if (!strcmp(tag.getName(), "list")) {
327  if ((!tag.isEndTag()) && (!tag.isEmpty())) {
328 
329  SWBuf rend = tag.getAttribute("rend");
330 
331  u->lastHi = rend;
332  if (rend == "numbered") {
333  buf += "<ol>\n";
334  }
335  else if (rend == "lettered") {
336  buf += "<ol type=\"A\">\n";
337  }
338  else if (rend == "bulleted") {
339  buf += "<ul>\n";
340  }
341  else {
342  buf += "<ul class=\"list ";
343  buf += rend.c_str();
344  buf += "\">";
345  }
346  }
347  else if (tag.isEndTag()) {
348  SWBuf rend = u->lastHi;
349  if (rend == "numbered") {
350  buf += "</ol>\n>";
351  }
352  else if (rend == "lettered") {
353  buf += "</ol>\n";
354  }
355  else if (rend == "bulleted") {
356  buf += "</ul>\n";
357  }
358  else {
359  buf += "</ul>\n";
360  }
361  u->supressAdjacentWhitespace = true;
362  }
363  }
364  else if (!strcmp(tag.getName(), "item")) {
365  if ((!tag.isEndTag()) && (!tag.isEmpty())) {
366  buf += "<li>";
367  }
368  else if (tag.isEndTag()) {
369  buf += "</li>\n";
370  }
371  }
372  else {
373  return false; // we still didn't handle token
374  }
375 
376  }
377  return true;
378 }
SWBuf & appendFormatted(const char *format,...)
Definition: swbuf.cpp:81
Definition: swbuf.h:47
virtual const char * getConfigEntry(const char *key) const
Definition: swmodule.cpp:1159
const SWModule * module
Definition: swbasicfilter.h:42
Definition: utilxml.h:38
bool substituteToken(SWBuf &buf, const char *token)
char * getRawData()
Definition: swbuf.h:379
const char * c_str() const
Definition: swbuf.h:158
unsigned long size() const
Definition: swbuf.h:185
int size
Definition: regex.c:5043
bool renderNoteNumbers
Definition: teihtmlhref.h:36
static const SWBuf encode(const char *urlText)
Definition: url.cpp:231
void setSize(unsigned long len)
Definition: swbuf.h:255
bool SWBasicFilter::passAllowedEscapeString ( SWBuf buf,
const char *  escString 
)
protectedinherited

This passes allowed escapeStrings

Definition at line 223 of file swbasicfilter.cpp.

223  {
224  StringSet::iterator it;
225 
226  if (!escStringCaseSensitive) {
227  char *tmp = 0;
228  stdstr(&tmp, escString);
229  toupperstr(tmp);
230  it = p->escPassSet.find(tmp);
231  delete [] tmp;
232  } else
233  it = p->escPassSet.find(escString);
234 
235  if (it != p->escPassSet.end()) {
236  appendEscapeString(buf, escString);
237  return true;
238  }
239 
240  return false;
241 }
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
bool escStringCaseSensitive
Definition: swbasicfilter.h:74
char * toupperstr(char *t, unsigned int max=0)
Definition: stringmgr.h:107
Private * p
Definition: swbasicfilter.h:82
void appendEscapeString(SWBuf &buf, const char *escString)
virtual bool SWBasicFilter::processStage ( char  ,
SWBuf ,
char *&  ,
BasicFilterUserData  
)
inlineprotectedvirtualinherited

Reimplemented in OSISPlain.

Definition at line 185 of file swbasicfilter.h.

185 { return false; }
char SWBasicFilter::processText ( SWBuf text,
const SWKey key = 0,
const SWModule module = 0 
)
virtualinherited

This method processes and appropriately modifies the text given it for a particular filter task

Parameters
textThe text to be filtered/converted
keyCurrent key That was used.
moduleCurrent module.
Returns
0

Implements SWFilter.

Reimplemented in ThMLRTF, OSISOSIS, and OSISRTF.

Definition at line 315 of file swbasicfilter.cpp.

315  {
316  char *from;
317  char token[4096];
318  int tokpos = 0;
319  bool intoken = false;
320  bool inEsc = false;
321  int escStartPos = 0, escEndPos = 0;
322  int tokenStartPos = 0, tokenEndPos = 0;
323  SWBuf lastTextNode;
324  BasicFilterUserData *userData = createUserData(module, key);
325 
326  SWBuf orig = text;
327  from = orig.getRawData();
328  text = "";
329 
330  if (processStages & INITIALIZE) {
331  if (processStage(INITIALIZE, text, from, userData)) { // processStage handled it all
332  delete userData;
333  return 0;
334  }
335  }
336 
337  for (;*from; from++) {
338 
339  if (processStages & PRECHAR) {
340  if (processStage(PRECHAR, text, from, userData)) // processStage handled this char
341  continue;
342  }
343 
344  if (*from == tokenStart[tokenStartPos]) {
345  if (tokenStartPos == (tokenStartLen - 1)) {
346  intoken = true;
347  tokpos = 0;
348  token[0] = 0;
349  token[1] = 0;
350  token[2] = 0;
351  inEsc = false;
352  }
353  else tokenStartPos++;
354  continue;
355  }
356 
357  if (*from == escStart[escStartPos]) {
358  if (escStartPos == (escStartLen - 1)) {
359  intoken = true;
360  tokpos = 0;
361  token[0] = 0;
362  token[1] = 0;
363  token[2] = 0;
364  inEsc = true;
365  }
366  else escStartPos++;
367  continue;
368  }
369 
370  if (inEsc) {
371  if (*from == escEnd[escEndPos]) {
372  if (escEndPos == (escEndLen - 1)) {
373  intoken = inEsc = false;
374  userData->lastTextNode = lastTextNode;
375 
376  if (!userData->suspendTextPassThru) { //if text through is disabled no tokens should pass, too
377  if ((!handleEscapeString(text, token, userData)) && (passThruUnknownEsc)) {
378  appendEscapeString(text, token);
379  }
380  }
381  escEndPos = escStartPos = tokenEndPos = tokenStartPos = 0;
382  lastTextNode = "";
383  continue;
384  }
385  }
386  }
387 
388  if (!inEsc) {
389  if (*from == tokenEnd[tokenEndPos]) {
390  if (tokenEndPos == (tokenEndLen - 1)) {
391  intoken = false;
392  userData->lastTextNode = lastTextNode;
393  if ((!handleToken(text, token, userData)) && (passThruUnknownToken)) {
394  text += tokenStart;
395  text += token;
396  text += tokenEnd;
397  }
398  escEndPos = escStartPos = tokenEndPos = tokenStartPos = 0;
399  lastTextNode = "";
400  if (!userData->suspendTextPassThru) {
401  userData->lastSuspendSegment.size(0);
402  }
403  continue;
404  }
405  }
406  }
407 
408  if (intoken) {
409  if (tokpos < 4090) {
410  token[tokpos++] = *from;
411  token[tokpos+2] = 0;
412  }
413  }
414  else {
415  if ((!userData->supressAdjacentWhitespace) || (*from != ' ')) {
416  if (!userData->suspendTextPassThru) {
417  text.append(*from);
418  }
419  else userData->lastSuspendSegment.append(*from);
420  lastTextNode.append(*from);
421  }
422  userData->supressAdjacentWhitespace = false;
423  }
424 
425  if (processStages & POSTCHAR)
426  processStage(POSTCHAR, text, from, userData);
427 
428  }
429 
430  if (processStages & FINALIZE)
431  processStage(FINALIZE, text, from, userData);
432 
433  delete userData;
434  return 0;
435 }
static const char PRECHAR
Definition: swbasicfilter.h:97
Definition: swbuf.h:47
static const char POSTCHAR
Definition: swbasicfilter.h:98
char * tokenStart
Definition: swbasicfilter.h:64
virtual bool handleToken(SWBuf &buf, const char *token, BasicFilterUserData *userData)
bool passThruUnknownEsc
Definition: swbasicfilter.h:77
virtual bool handleEscapeString(SWBuf &buf, const char *escString, BasicFilterUserData *userData)
bool passThruUnknownToken
Definition: swbasicfilter.h:76
static const char FINALIZE
Definition: swbasicfilter.h:99
char * getRawData()
Definition: swbuf.h:379
SWBuf & append(const char *str, long max=-1)
Definition: swbuf.h:274
virtual bool processStage(char, SWBuf &, char *&, BasicFilterUserData *)
virtual BasicFilterUserData * createUserData(const SWModule *module, const SWKey *key)
Definition: swbasicfilter.h:91
unsigned long size() const
Definition: swbuf.h:185
static const char INITIALIZE
Definition: swbasicfilter.h:96
void appendEscapeString(SWBuf &buf, const char *escString)
void SWBasicFilter::removeAllowedEscapeString ( const char *  findString)
protectedinherited

Unregisters an esc control sequence that can pass unchanged

Definition at line 169 of file swbasicfilter.cpp.

169  {
170  if (p->escPassSet.find(findString) != p->escPassSet.end()) {
171  p->escPassSet.erase( p->escPassSet.find(findString) );
172  }
173 }
Private * p
Definition: swbasicfilter.h:82
void SWBasicFilter::removeEscapeStringSubstitute ( const char *  findString)
protectedinherited

Unregisters an esc control sequence

Definition at line 189 of file swbasicfilter.cpp.

189  {
190  if (p->escSubMap.find(findString) != p->escSubMap.end()) {
191  p->escSubMap.erase( p->escSubMap.find(findString) );
192  }
193 }
Private * p
Definition: swbasicfilter.h:82
void SWBasicFilter::removeTokenSubstitute ( const char *  findString)
protectedinherited

Unregisters a simple token substitute

Definition at line 149 of file swbasicfilter.cpp.

149  {
150  if (p->tokenSubMap.find(findString) != p->tokenSubMap.end()) {
151  p->tokenSubMap.erase( p->tokenSubMap.find(findString) );
152  }
153 }
DualStringMap tokenSubMap
Private * p
Definition: swbasicfilter.h:82
void SWBasicFilter::setEscapeEnd ( const char *  escEnd)
protectedinherited

Sets the end of escape sequence (by default ";").

Definition at line 297 of file swbasicfilter.cpp.

297  {
298  stdstr(&(this->escEnd), escEnd);
299  escEndLen = strlen(escEnd);
300 }
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
void SWBasicFilter::setEscapeStart ( const char *  escStart)
protectedinherited

Sets the beginning of escape sequence (by default "&").

Definition at line 291 of file swbasicfilter.cpp.

291  {
292  stdstr(&(this->escStart), escStart);
293  escStartLen = strlen(escStart);
294 }
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
void SWBasicFilter::setEscapeStringCaseSensitive ( bool  val)
protectedinherited

Are escapeStrings case sensitive or not? Call this function before addEscapeStingSubstitute()

Definition at line 131 of file swbasicfilter.cpp.

131  {
133 }
bool escStringCaseSensitive
Definition: swbasicfilter.h:74
void SWBasicFilter::setPassThruNumericEscapeString ( bool  val)
protectedinherited

Sets whether to pass thru a numeric escape sequence unchanged or allow it to be handled otherwise. Default is false.

Definition at line 121 of file swbasicfilter.cpp.

121  {
122  passThruUnknownEsc = val;
123 }
bool passThruUnknownEsc
Definition: swbasicfilter.h:77
void SWBasicFilter::setPassThruUnknownEscapeString ( bool  val)
protectedinherited

Sets whether to pass thru an unknown escape sequence unchanged or just remove it. Default is false.

Definition at line 116 of file swbasicfilter.cpp.

116  {
117  passThruUnknownEsc = val;
118 }
bool passThruUnknownEsc
Definition: swbasicfilter.h:77
void SWBasicFilter::setPassThruUnknownToken ( bool  val)
protectedinherited

Sets whether to pass thru an unknown token unchanged or just remove it. Default is false.

Definition at line 111 of file swbasicfilter.cpp.

111  {
112  passThruUnknownToken = val;
113 }
bool passThruUnknownToken
Definition: swbasicfilter.h:76
void TEIHTMLHREF::setRenderNoteNumbers ( bool  val = true)
inline

Definition at line 53 of file teihtmlhref.h.

53 { renderNoteNumbers = val; }
bool renderNoteNumbers
Definition: teihtmlhref.h:36
virtual void SWBasicFilter::setStageProcessing ( char  stages)
inlineprotectedvirtualinherited

Definition at line 186 of file swbasicfilter.h.

186 { processStages = stages; } // see STATICs up above
void SWBasicFilter::setTokenCaseSensitive ( bool  val)
protectedinherited

Are tokens case sensitive (like in GBF) or not? Call this function before addTokenSubstitute()

Definition at line 126 of file swbasicfilter.cpp.

126  {
127  tokenCaseSensitive = val;
128 }
bool tokenCaseSensitive
Definition: swbasicfilter.h:75
void SWBasicFilter::setTokenEnd ( const char *  tokenEnd)
protectedinherited

Sets the end of token start sequence (by default ">").

Definition at line 309 of file swbasicfilter.cpp.

309  {
310  stdstr(&(this->tokenEnd), tokenEnd);
311  tokenEndLen = strlen(tokenEnd);
312 }
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
void SWBasicFilter::setTokenStart ( const char *  tokenStart)
protectedinherited

Sets the beginning of token start sequence (by default "<").

Definition at line 303 of file swbasicfilter.cpp.

303  {
304  stdstr(&(this->tokenStart), tokenStart);
305  tokenStartLen = strlen(tokenStart);
306 }
char * tokenStart
Definition: swbasicfilter.h:64
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
bool SWBasicFilter::substituteEscapeString ( SWBuf buf,
const char *  escString 
)
protectedinherited

This function performs the substitution of escapeStrings

Definition at line 253 of file swbasicfilter.cpp.

253  {
254  DualStringMap::iterator it;
255 
256  if (*escString == '#') {
257  return handleNumericEscapeString(buf, escString);
258  }
259 
260  if (passAllowedEscapeString(buf, escString)) {
261  return true;
262  }
263 
264  if (!escStringCaseSensitive) {
265  char *tmp = 0;
266  stdstr(&tmp, escString);
267  toupperstr(tmp);
268  it = p->escSubMap.find(tmp);
269  delete [] tmp;
270  } else
271  it = p->escSubMap.find(escString);
272 
273  if (it != p->escSubMap.end()) {
274  buf += it->second.c_str();
275  return true;
276  }
277  return false;
278 }
virtual bool handleNumericEscapeString(SWBuf &buf, const char *escString)
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
const char * c_str() const
Definition: swbuf.h:158
bool escStringCaseSensitive
Definition: swbasicfilter.h:74
bool passAllowedEscapeString(SWBuf &buf, const char *escString)
char * toupperstr(char *t, unsigned int max=0)
Definition: stringmgr.h:107
Private * p
Definition: swbasicfilter.h:82
bool SWBasicFilter::substituteToken ( SWBuf buf,
const char *  token 
)
protectedinherited

This function performs the substitution of tokens

Definition at line 196 of file swbasicfilter.cpp.

196  {
197  DualStringMap::iterator it;
198 
199  if (!tokenCaseSensitive) {
200  char *tmp = 0;
201  stdstr(&tmp, token);
202  toupperstr(tmp);
203  it = p->tokenSubMap.find(tmp);
204  delete [] tmp;
205  } else
206  it = p->tokenSubMap.find(token);
207 
208  if (it != p->tokenSubMap.end()) {
209  buf += it->second.c_str();
210  return true;
211  }
212  return false;
213 }
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
Definition: utilstr.h:44
const char * c_str() const
Definition: swbuf.h:158
bool tokenCaseSensitive
Definition: swbasicfilter.h:75
DualStringMap tokenSubMap
char * toupperstr(char *t, unsigned int max=0)
Definition: stringmgr.h:107
Private * p
Definition: swbasicfilter.h:82

Member Data Documentation

const char SWBasicFilter::FINALIZE = 8
staticprotectedinherited

Definition at line 99 of file swbasicfilter.h.

const char SWBasicFilter::INITIALIZE = 1
staticprotectedinherited

Definition at line 96 of file swbasicfilter.h.

const char SWBasicFilter::POSTCHAR = 4
staticprotectedinherited

Definition at line 98 of file swbasicfilter.h.

const char SWBasicFilter::PRECHAR = 2
staticprotectedinherited

Definition at line 97 of file swbasicfilter.h.

bool TEIHTMLHREF::renderNoteNumbers
private

Definition at line 36 of file teihtmlhref.h.


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