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

#include <rtfhtml.h>

+ Inheritance diagram for RTFHTML:
+ Collaboration diagram for RTFHTML:

Public Member Functions

virtual const char * getHeader () const
 
virtual char processText (SWBuf &text, const SWKey *key=0, const SWModule *module=0)
 
 RTFHTML ()
 

Detailed Description

this filter converts RTF text into HTML text

Definition at line 34 of file rtfhtml.h.

Constructor & Destructor Documentation

SWORD_NAMESPACE_START RTFHTML::RTFHTML ( )

Definition at line 33 of file rtfhtml.cpp.

34 {
35 }

Member Function Documentation

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 ""; }
char RTFHTML::processText ( SWBuf text,
const SWKey key = 0,
const SWModule module = 0 
)
virtual

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.

Definition at line 38 of file rtfhtml.cpp.

39 {
40  bool center = false;
41 
42  const char *from;
43  SWBuf orig = text;
44  from = orig.c_str();
45  for (text = ""; *from; from++)
46  {
47  if (*from == '\\') // a RTF command
48  {
49  // \u12345?
50  if ( *(from+1) == 'u' && (*(from+2) == '-' || isdigit(*(from+2)))) {
51  from += 2;
52  const char *end = from;
53  while (isdigit(*++end));
54  SWBuf num;
55  num.append(from, end-from);
56  SW_s16 n = atoi(num.c_str());
57  SW_u32 u = (SW_u16)n;
58  getUTF8FromUniChar(u, &text);
59  from += (end-from);
60  continue;
61  }
62  if ( !strncmp(from+1, "pard", 4) )
63  //(from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r') && (from[4] == 'd'))
64  { // switch all modifiers off
65  if (center)
66  {
67  text += "</center>";
68  center = false;
69  }
70  from += 4;
71  continue;
72  }
73  if ( !strncmp(from+1, "par", 3) )
74  //(from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r'))
75  {
76  text += "<p/>\n";
77  from += 3;
78  continue;
79  }
80  if (from[1] == ' ')
81  {
82  from += 1;
83  continue;
84  }
85  if ( !strncmp(from+1, "qc", 2) )
86  //(from[1] == 'q') && (from[2] == 'c')) // center on
87  {
88  if (!center)
89  {
90  text += "<center>";
91  center = true;
92  }
93  from += 2;
94  continue;
95  }
96  }
97 
98  text += *from;
99  }
100  return 0;
101 }
Definition: swbuf.h:47
const char * c_str() const
Definition: swbuf.h:158
SWBuf & append(const char *str, long max=-1)
Definition: swbuf.h:274
unsigned short SW_u16
Definition: sysdata.h:38
SWBuf * getUTF8FromUniChar(SW_u32 uchar, SWBuf *appendTo)
Definition: utilstr.h:165
unsigned int SW_u32
Definition: sysdata.h:41
signed short SW_s16
Definition: sysdata.h:37

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