[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice
Subject:    Re: RTF Filter Development
From:       David Faure <david () mandrakesoft ! com>
Date:       2000-06-09 19:07:01
[Download RAW message or body]

On Fri, Jun 09, 2000 at 02:57:26PM -0400, David Levitan wrote:
> Hi,
> I'm currently starting work on an RTF filter, and need a few comments on
> my ideas.
Good news ! :-)

> I want to create a filter that is easily extendable. Microsoft
> is currently adding new features, and as is evident by their
> specification of RTF, more and more features are added with each version
> of Word (http://msdn.microsoft.com/library/specs/rtfspec.htm).
> For those who have never looked at the spec of an RTF file, an RTF file
> is an ASCII file that contains control words, groups, and the text
> itself. Control words are start with a \ and end (usually) with a space,
> groups use { }. My idea is to have a seperate function for each control
> word, and store a pointer to that function in an array/hash. Whenever
> the filter finds a control word as it goes through the incoming file, it
> reads the word, looks it up in an array/hash, and then calls the
> appropriate function using the pointer that was stored. The function
> could then do whatever it needed to convert the control word in the
> Kword syntax. If there is no record of the control word, it is skipped.
> This format would allow an easy way to extend the filters easily. As I
> said previously, MS constantly adds new control words, and it is helpful
> to have an easy way to add the new control words to the filters.
> What does everybody think about this type of filter? Any comments on
> performance? Any better suggestions?

The idea sounds good to me.
QDict comes to mind, for implementing the hash.

Note that the idea is valid only if the function name only (by itself) determines
the way to handle it. This doesn't work if the context has much importance.
(The notion of context can be implemented separately, of course, but if the
context makes functions behave completely differently, then the initial lookup
doesn't help much).

(Disclaimer: I'm clueless about rtf).
Interesting. If it models everything by nested groups and functions with args,
it's a sort of XML before XML existed :) (I mean, it would be very easy to model
the same thing with XML - not that this would be particularly useful though :-)

-- 
David FAURE, david@mandrakesoft.com, faure@kde.org
http://home.clara.net/faure/
KDE, Making The Future of Computing Available Today
See http://www.kde.org/kde1-and-kde2.html for how to set up KDE 2

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic