/** * Interface that describes an object that can accept/represent a * document. * Usually, something that already has some representation of a document, * will use this interface on another object, to transfer its internal * document, to the external object *

* Note that there is an implied concept of "state" here. If you call
* addString("first line");
* changeColor(3);
* addString("secondline");
* you expect the first and second lines to be different colors. *

* Initial guesses on what we need here, are judged by what is in the * RTF spec. There is no guarantee that an object implementing this interface, * actually DOES anything with each function! :-) *

* All errors are currently handled by throwing IOExceptions, even * if the error isn't strictly an I/O error. *

* @author Philip Brown * @version @(#) DocInterface.java 2.1@(#) * */ interface DocInterface { /** * startInput and endInput are neccessary performance tweaks. * They allow the object to set up various caches. Otherwise, it * would have to do a lot of slow rechecking for each new bit. * Thus, you MUST USE THESE FUNCTIONS, ALWAYS, when starting and * ending input to a DocInterface object. * Note that all a window DocInterface has to do with the filename, * is just display it. Or even ignore it. So if you know what * type of object you are "really" talking to , you might even * just have a null filename for startInput() */ public void startInput(String filename) throws java.io.IOException; public void endInput() throws java.io.IOException; /* Your basic text tweaks go in this section */ public void addString(String newtext) throws java.io.IOException; public void changeFont(int fontindex) throws java.io.IOException; public void changeColor(int colorindex) throws java.io.IOException; /** fonts should be defined here. * use java.awt.Font.{PLAIN|BOLD|ITALIC} for "weight". */ public void describeFonts(FontManager fman) throws java.io.IOException; public void addColorIndex(int cnum, int rgb) throws java.io.IOException; /* formatting tweaks like border, etc go here */ public void setParagraphIndent(int ptindent) throws java.io.IOException; public void setLineWidth(int ptwidth) throws java.io.IOException; public void insertParagraphBreak() throws java.io.IOException; public void insertPageBreak() throws java.io.IOException; public void setLeftMargin(int ptdist) throws java.io.IOException; public void setRightMargin(int ptdist) throws java.io.IOException; public void setTopMargin(int ptdist) throws java.io.IOException; public void setBottomMargin(int ptdist) throws java.io.IOException; /* should I have a startSection()/endSection() thing here? * But I don't really understand what the heck they actually DO. * Are they even really useful outside the context of an RTF file? * * Looking at raw RTF files generated from MS-word, it's a damn mess. * Sigh... frigging microsloth screwing up their own format... */ }