Mostly adapted to the refactored RTF classes hierarchy.

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@10564 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2005-01-03 02:04:44 +00:00
parent a7e0bca0f7
commit 64214d4cce
4 changed files with 30 additions and 27 deletions

View File

@ -120,7 +120,9 @@ RTFTranslator::Identify(BPositionIO *stream,
if (outType != B_TRANSLATOR_TEXT && outType != B_STYLED_TEXT_FORMAT)
return B_NO_TRANSLATOR;
status_t status = RTFHeader::Identify(*stream);
RTF::Parser parser(*stream);
status_t status = parser.Identify();
if (status != B_OK)
return B_NO_TRANSLATOR;
@ -149,8 +151,10 @@ RTFTranslator::Translate(BPositionIO *source,
if (outType != B_TRANSLATOR_TEXT && outType != B_STYLED_TEXT_FORMAT)
return B_NO_TRANSLATOR;
RTFHeader header;
status_t status = RTFHeader::Parse(*source, header);
RTF::Parser parser(*source);
RTF::Header header;
status_t status = parser.Parse(header);
if (status != B_OK)
return status;

View File

@ -15,7 +15,6 @@
#include <File.h>
#include <ByteOrder.h>
#include <fs_attr.h>
#include "BaseTranslator.h"
#define RTF_TRANSLATOR_VERSION B_TRANSLATION_MAKE_VER(1, 0, 0)

View File

@ -52,7 +52,7 @@ AppServerConnection::~AppServerConnection()
static size_t
get_text_for_command(RTFCommand *command, char *text, size_t size)
get_text_for_command(RTF::Command *command, char *text, size_t size)
{
const char *name = command->Name();
@ -89,23 +89,23 @@ get_style(BList &runs, text_run *run, int32 offset)
static text_run_array *
get_text_run_array(RTFHeader &header)
get_text_run_array(RTF::Header &header)
{
// collect styles
RTFIterator iterator(header, RTF_TEXT);
RTF::Iterator iterator(header, RTF::TEXT_DESTINATION);
text_run *current = NULL;
int32 offset = 0;
BList runs;
while (iterator.HasNext()) {
RTFElement *element = iterator.Next();
if (RTFText *text = dynamic_cast<RTFText *>(element)) {
offset += text->TextLength();
RTF::Element *element = iterator.Next();
if (RTF::Text *text = dynamic_cast<RTF::Text *>(element)) {
offset += text->Length();
continue;
}
RTFCommand *command = dynamic_cast<RTFCommand *>(element);
RTF::Command *command = dynamic_cast<RTF::Command *>(element);
if (command == NULL)
continue;
@ -149,20 +149,20 @@ get_text_run_array(RTFHeader &header)
status_t
write_plain_text(RTFHeader &header, BDataIO &target)
write_plain_text(RTF::Header &header, BDataIO &target)
{
RTFIterator iterator(header, RTF_TEXT);
RTF::Iterator iterator(header, RTF::TEXT_DESTINATION);
while (iterator.HasNext()) {
RTFElement *element = iterator.Next();
RTF::Element *element = iterator.Next();
char buffer[1024];
const char *string = NULL;
size_t size = 0;
if (RTFText *text = dynamic_cast<RTFText *>(element)) {
string = text->Text();
size = text->TextLength();
} else if (RTFCommand *command = dynamic_cast<RTFCommand *>(element)) {
if (RTF::Text *text = dynamic_cast<RTF::Text *>(element)) {
string = text->String();
size = text->Length();
} else if (RTF::Command *command = dynamic_cast<RTF::Command *>(element)) {
size = get_text_for_command(command, buffer, sizeof(buffer));
if (size != 0)
string = buffer;
@ -186,18 +186,18 @@ write_plain_text(RTFHeader &header, BDataIO &target)
status_t
convert_to_stxt(RTFHeader &header, BDataIO &target)
convert_to_stxt(RTF::Header &header, BDataIO &target)
{
// count text bytes
size_t textSize = 0;
RTFIterator iterator(header, RTF_TEXT);
RTF::Iterator iterator(header, RTF::TEXT_DESTINATION);
while (iterator.HasNext()) {
RTFElement *element = iterator.Next();
if (RTFText *text = dynamic_cast<RTFText *>(element)) {
textSize += text->TextLength();
} else if (RTFCommand *command = dynamic_cast<RTFCommand *>(element)) {
RTF::Element *element = iterator.Next();
if (RTF::Text *text = dynamic_cast<RTF::Text *>(element)) {
textSize += text->Length();
} else if (RTF::Command *command = dynamic_cast<RTF::Command *>(element)) {
textSize += get_text_for_command(command, NULL, 0);
}
}
@ -294,7 +294,7 @@ convert_to_stxt(RTFHeader &header, BDataIO &target)
status_t
convert_to_plain_text(RTFHeader &header, BPositionIO &target)
convert_to_plain_text(RTF::Header &header, BPositionIO &target)
{
// put out main text

View File

@ -10,7 +10,7 @@
#include <DataIO.h>
extern status_t convert_to_stxt(RTFHeader &header, BDataIO &target);
extern status_t convert_to_plain_text(RTFHeader &header, BPositionIO &target);
extern status_t convert_to_stxt(RTF::Header &header, BDataIO &target);
extern status_t convert_to_plain_text(RTF::Header &header, BPositionIO &target);
#endif /* CONVERT_H */