/** Base class for rtflib exceptions.
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
-
public class RtfException extends java.io.IOException {
+ /**
+ * @param reason Description of reason for Exception.
+ */
public RtfException(String reason) {
super(reason);
}
/** Thrown when a method call would lead to an invalid RTF document structure.
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
-
public class RtfStructureException
extends RtfException {
+ /**
+ * @param reason Description of reason for exception.
+ */
public RtfStructureException(String reason) {
super(reason);
}
*/
float getColumnWidth();
- /** @return current column iteration index */
- int getColumnIndex();
+ /** @return current column iteration index */
+ int getColumnIndex();
- /** @return number of columns */
- int getNumberOfColumns();
+ /** @return number of columns */
+ int getNumberOfColumns();
}
\ No newline at end of file
public BasicLink() {
}
- /** generate the body of the test document */
+ /** generate the body of the test document
+ * @param rda RtfDocumentArea
+ * @param sect RtfSection
+ * @throws IOException for I/O Errors
+ */
protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws IOException {
RtfParagraph p = sect.newParagraph ();
p.newLineBreak();
*/
public class CreateTestDocuments {
+
+ /**
+ * package name for the testdocs
+ */
public static final String TESTDOCS_PACKAGE = "org.apache.fop.rtf.rtflib.testdocs";
/** List of all TestDocument subclasses from this package */
- private static final String [] classNames = {
+ private static final String [] CLASS_NAMES = {
"SimpleDocument",
"TextAttributes",
"SimpleTable",
throw new IOException("output directory (" + outDir + ") must exist and be writable");
}
- for (int i = 0; i < classNames.length; i++) {
- createOneTestDocument(classNames[i], outDir);
+ for (int i = 0; i < CLASS_NAMES.length; i++) {
+ createOneTestDocument(CLASS_NAMES[i], outDir);
}
}
td.generateOutput();
}
- /** execute this to create test documents from all classes listed in classNames array */
+ /** execute this to create test documents from all classes listed in classNames array
+ * @param args String array of arguments
+ * @throws Exception for errors
+ */
public static void main(String args[])
throws Exception {
if (args.length < 1) {
*/
class MergedTableCells extends TestDocument {
+ static final int MM_TO_TWIPS = (int)(1440f / 25.4f);
+
/** generate the body of the test document */
protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
throws IOException {
sect.newParagraph().newText("This document contains a table with some merged cells.");
final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo());
- final int MM_TO_TWIPS = (int)(1440f / 25.4f);
// first row, test horizontal merging
{
*/
public class ParagraphAlignment extends TestDocument {
+ /**
+ * Constructor
+ */
public ParagraphAlignment() {
}
+
+ /**
+ * Generate the document.
+ * @param rda RtfDocumentArea
+ * @param sect RtfSection
+ * @throws java.io.IOException for I/O errors
+ */
protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws java.io.IOException
{
RtfAttributes attr = new RtfAttributes ();
*/
class SimpleTable extends TestDocument {
/** generate the body of the test document */
+ static final int MAX_ROW = 2;
+ static final int MAX_COL = 3;
+ static final int INCH_TO_TWIPS = 1440;
+ static final int C1W = 4;
+
protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
throws IOException {
final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo());
- final int MAX_ROW = 2;
- final int MAX_COL = 3;
-
- final int INCH_TO_TWIPS = 1440;
- final int c1w = 4;
- tbl.newTableRow().newTableCell(c1w * INCH_TO_TWIPS).newParagraph().newText
- ("Here's a table row with just one cell, width " + c1w + "''");
+ tbl.newTableRow().newTableCell(C1W * INCH_TO_TWIPS).newParagraph().newText
+ ("Here's a table row with just one cell, width " + C1W + "''");
for (int row = 0; row < MAX_ROW; row++) {
final RtfTableRow r = tbl.newTableRow();
*/
abstract class TestDocument {
- private File m_output;
+ private File output;
final void setOutputDir(File outDir)
throws IOException {
- m_output = new File(outDir, getRtfFilename());
+ output = new File(outDir, getRtfFilename());
}
final String getRtfFilename() {
final void generateOutput()
throws IOException {
- debugMsg("Generating document " + m_output + "...");
- final RtfFile f = new RtfFile(new FileWriter(m_output));
+ debugMsg("Generating document " + output + "...");
+ final RtfFile f = new RtfFile(new FileWriter(output));
final RtfDocumentArea rda = f.startDocumentArea();
final RtfSection sect = rda.newSection();
addIntroComments(sect);
//////////////////////////////////////////////////
/** Defines the case, if image is not supported */
- public static int I_NOT_SUPPORTED = -1;
-
- public static int I_EMF = 0;
- public static int I_PNG = 1;
- public static int I_JPG = 2;
+ public static final int I_NOT_SUPPORTED = -1;
+ /** Integer equivalent for EMF */
+ public static final int I_EMF = 0;
+ /** Integer equivalent for PNG */
+ public static final int I_PNG = 1;
+ /** Integer equivalent for JPG */
+ public static final int I_JPG = 2;
/** Defines the RTF properties */
- public static String [] RTF_TAGS = new String []
+ public static final String [] RTF_TAGS = new String []
{
"emfblip", "pngblip", "jpegblip"
};
- public static int I_TO_CONVERT_BASIS = 50;
- public static int I_GIF = 50;
- public static int I_JPG_C = 51;
+ public static final int I_TO_CONVERT_BASIS = 50;
+ public static final int I_GIF = 50;
+ public static final int I_JPG_C = 51;
/** Defines the types for converting rtf supported image types */
- public static int [] CONVERT_TO = new int []
+ public static final int [] CONVERT_TO = new int []
{
I_JPG, I_JPG
};
/** EMF file extension */
- public static String EMF_EXT = "emf";
+ public static final String EMF_EXT = "emf";
/** PNG file extension */
- public static String PNG_EXT = "png";
+ public static final String PNG_EXT = "png";
/** JPG file extension */
- public static String JPG_EXT = "jpg";
+ public static final String JPG_EXT = "jpg";
/** JPEG file extension */
- public static String JPEG_EXT = "jpeg";
+ public static final String JPEG_EXT = "jpeg";
/** GIF file extension */
- public static String GIF_EXT = "gif";
+ public static final String GIF_EXT = "gif";
/** Defines the file extensions and the RTF property belongs to */
- public static Hashtable SUPPORTED_IMAGE_TYPES = new Hashtable ();
+ public static final Hashtable SUPPORTED_IMAGE_TYPES = new Hashtable ();
static {
SUPPORTED_IMAGE_TYPES.put (EMF_EXT, new Integer (I_EMF));
SUPPORTED_IMAGE_TYPES.put (PNG_EXT, new Integer (I_PNG));
*
* @param value String with digits
*
- * @return
- * -1 There is no digit\n
- * number The digits as integer
+ * @return -1 There is no digit
+ * number The digits as integer
*/
public static int getInt (String value) {
String retString = new String ();
*
* @param value String with digits
*
- * @return
- * true The string contains a % value
- * false Other string
+ * @return true The string contains a % value
+ * false Other string
*/
public static boolean isPercent (String value) {
if (value.endsWith ("%")) {
* @param searchAt Position to start compare
* @param searchForward Direction to compare byte arrays
*
- * @return
- * true If equal\n
- * false If different
+ * @return true If equal
+ * false If different
*/
public static boolean compareHexValues (byte[] pattern, byte[] data, int searchAt,
boolean searchForward) {
* Determines a integer value from a hexadecimal byte array.
*
* @param data Image
- * @param start Start index to read from
- * @param end End index until to read
+ * @param startAt Start index to read from
+ * @param length Number of data elements to read
+ * @param searchForward True if searching forward, False if not (??)
*
- * @return A number
+ * @return integer
*/
public static int getIntFromByteArray (byte[] data, int startAt, int length,
boolean searchForward) {