summaryrefslogtreecommitdiff
path: root/src/modules/filters/rtfhtml.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules/filters/rtfhtml.cpp')
-rw-r--r--src/modules/filters/rtfhtml.cpp59
1 files changed, 20 insertions, 39 deletions
diff --git a/src/modules/filters/rtfhtml.cpp b/src/modules/filters/rtfhtml.cpp
index f0b842b..6b228fb 100644
--- a/src/modules/filters/rtfhtml.cpp
+++ b/src/modules/filters/rtfhtml.cpp
@@ -16,54 +16,41 @@
***************************************************************************/
#include <stdlib.h>
-#include <string.h>
#include <rtfhtml.h>
+SWORD_NAMESPACE_START
RTFHTML::RTFHTML() {
}
-char RTFHTML::ProcessText(char *text, int maxlen, const SWKey *key, const SWModule *module)
+char RTFHTML::processText(SWBuf &text, const SWKey *key, const SWModule *module)
{
- char *to, *from;
- int len;
bool center = false;
- len = strlen(text) + 1; // shift string to right of buffer
- if (len < maxlen) {
- memmove(&text[maxlen - len], text, len);
- from = &text[maxlen - len];
- }
- else from = text; // -------------------------------
- for (to = text; *from; from++) {
+ const char *from;
+ SWBuf orig = text;
+ from = orig.c_str();
+ for (text = ""; *from; from++)
+ {
if (*from == '\\') // a RTF command
{
- if ((from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r') && (from[4] == 'd'))
- { // switch all modifier off
+ if ( !strncmp(from+1, "pard", 4) )
+ //(from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r') && (from[4] == 'd'))
+ { // switch all modifiers off
if (center)
{
- *to++ = '<';
- *to++ = '/';
- *to++ = 'C';
- *to++ = 'E';
- *to++ = 'N';
- *to++ = 'T';
- *to++ = 'E';
- *to++ = 'R';
- *to++ = '>';
+ text += "</CENTER>";
center = false;
}
from += 4;
continue;
}
- if ((from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r'))
+ if ( !strncmp(from+1, "par", 3) )
+ //(from[1] == 'p') && (from[2] == 'a') && (from[3] == 'r'))
{
- *to++ = '<';
- *to++ = 'P';
- *to++ = '>';
- *to++ = '\n';
+ text += "<P>\n";
from += 3;
continue;
}
@@ -72,18 +59,12 @@ char RTFHTML::ProcessText(char *text, int maxlen, const SWKey *key, const SWModu
from += 1;
continue;
}
- if ((from[1] == 'q') && (from[2] == 'c')) // center on
+ if ( !strncmp(from+1, "qc", 2) )
+ //(from[1] == 'q') && (from[2] == 'c')) // center on
{
if (!center)
{
- *to++ = '<';
- *to++ = 'C';
- *to++ = 'E';
- *to++ = 'N';
- *to++ = 'T';
- *to++ = 'E';
- *to++ = 'R';
- *to++ = '>';
+ text += "<CENTER>";
center = true;
}
from += 2;
@@ -91,9 +72,9 @@ char RTFHTML::ProcessText(char *text, int maxlen, const SWKey *key, const SWModu
}
}
- *to++ = *from;
+ text += *from;
}
- *to++ = 0;
- *to = 0;
return 0;
}
+
+SWORD_NAMESPACE_END