import java.io.IOException;
-public interface IRtfPageNumberCitationContainer
-{
- public RtfPageNumberCitation newPageNumberCitation(String id) throws IOException;
+public interface IRtfPageNumberCitationContainer {
+ RtfPageNumberCitation newPageNumberCitation(String id) throws IOException;
}
import java.io.IOException;
-public interface IRtfPageNumberContainer
-{
- public RtfPageNumber newPageNumber() throws IOException;
+public interface IRtfPageNumberContainer {
+ RtfPageNumber newPageNumber() throws IOException;
}
\ No newline at end of file
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
-public interface IRtfParagraphContainer
-{
+public interface IRtfParagraphContainer {
/** close current paragraph if any and start a new one with default attributes */
- public RtfParagraph newParagraph() throws IOException;
+ RtfParagraph newParagraph() throws IOException;
/** close current paragraph if any and start a new one with specified attributes */
- public RtfParagraph newParagraph(RtfAttributes attr) throws IOException;
+ RtfParagraph newParagraph(RtfAttributes attr) throws IOException;
}
\ No newline at end of file
public interface IRtfParagraphKeepTogetherContainer {
/** close current paragraph if any and start a new one */
- public RtfParagraphKeepTogether newParagraphKeepTogether() throws IOException;
+ RtfParagraphKeepTogether newParagraphKeepTogether() throws IOException;
}
\ No newline at end of file
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
-public interface IRtfTableContainer
-{
+public interface IRtfTableContainer {
/** close current table if any and start a new one */
- public RtfTable newTable(ITableColumnsInfo tc) throws IOException;
+ RtfTable newTable(ITableColumnsInfo tc) throws IOException;
/** close current table if any and start a new one
- * @param tc added by Boris Poudérous on july 2002 in order to process number-columns-spanned attribute
+ * @param tc added by Boris Poudérous on july 2002 in order to process
+ * number-columns-spanned attribute
**/
- public RtfTable newTable(RtfAttributes attrs, ITableColumnsInfo tc) throws IOException;
+ RtfTable newTable(RtfAttributes attrs, ITableColumnsInfo tc) throws IOException;
}
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
-public interface IRtfTextContainer
-{
+public interface IRtfTextContainer {
/** close current text run if any and start a new one with specified attributes
* @param str if not null, added to the RtfText created
*/
- public RtfText newText(String str,RtfAttributes attr) throws IOException;
+ RtfText newText(String str, RtfAttributes attr) throws IOException;
/** close current text run if any and start a new one with default attributes
* @param str if not null, added to the RtfText created
*/
- public RtfText newText(String str) throws IOException;
+ RtfText newText(String str) throws IOException;
/** add a line break */
- public void newLineBreak() throws IOException;
+ void newLineBreak() throws IOException;
/** text containers usually provide default attributes for all texts that they contain.
* This returns a copy of the container's attributes
*/
- public RtfAttributes getTextContainerAttributes();
+ RtfAttributes getTextContainerAttributes();
}
*
* @exception IOException on error
*/
- public RtfTemplate newTemplate (String str, RtfAttributes attr) throws IOException;
+ RtfTemplate newTemplate (String str, RtfAttributes attr) throws IOException;
}
public class ParagraphKeeptogetherContext {
- private static int m_paraKeepTogetherOpen=0;
- private static boolean m_paraResetProperties=false;
+ private static int m_paraKeepTogetherOpen = 0;
+ private static boolean m_paraResetProperties = false;
private static ParagraphKeeptogetherContext m_instance = null;
ParagraphKeeptogetherContext() {
* @return The instance of ParagraphKeeptogetherContext
*/
public static ParagraphKeeptogetherContext getInstance() {
- if (m_instance==null) m_instance = new ParagraphKeeptogetherContext();
+ if (m_instance == null) {
+ m_instance = new ParagraphKeeptogetherContext();
+ }
return m_instance;
}
- /** Return the level of current "keep whith next" paragraph */
+ /**
+ * @return the level of current "keep whith next" paragraph
+ */
public static int getKeepTogetherOpenValue() {
return m_paraKeepTogetherOpen;
}
/** Close a "keep whith next" paragraph */
public static void KeepTogetherClose() {
- if(m_paraKeepTogetherOpen > 0) {
+ if (m_paraKeepTogetherOpen > 0) {
m_paraKeepTogetherOpen--;
- //If the \pard control word is not present, the current paragraph inherits all paragraph properties.
+ //If the \pard control word is not present, the current paragraph
+ //inherits all paragraph properties.
//Also the next paragraph must reset the properties otherwise the \keepn don't stop.
- m_paraResetProperties= (m_paraKeepTogetherOpen==0);
+ m_paraResetProperties = (m_paraKeepTogetherOpen == 0);
}
}
/** Reset the flag if the paragraph properties have been resested */
public static void setParagraphResetPropertiesUsed() {
- m_paraResetProperties=false;
+ m_paraResetProperties = false;
}
}
/** RtfContainer that encloses footers */
public class RtfAfter extends RtfAfterBeforeBase {
/**RtfBefore attributes*/
- public final static String FOOTER = "footer";
- public final static String[] FOOTER_ATTR = new String[]{
+ public static final String FOOTER = "footer";
+ public static final String[] FOOTER_ATTR = new String[]{
FOOTER
};
RtfAfter(RtfSection parent, Writer w, RtfAttributes attrs) throws IOException {
- super(parent,w,attrs);
+ super(parent, w, attrs);
}
protected void writeMyAttributes() throws IOException {
- writeAttributes(m_attrib,FOOTER_ATTR);
+ writeAttributes(m_attrib, FOOTER_ATTR);
}
}
\ No newline at end of file
package org.apache.fop.rtf.rtflib.rtfdoc;
import java.io.Writer;
-import java.io.*;
-import java.util.*;
import java.io.IOException;
import org.apache.fop.rtf.rtflib.interfaces.ITableColumnsInfo;
abstract class RtfAfterBeforeBase
extends RtfContainer
-implements IRtfParagraphContainer, IRtfExternalGraphicContainer,IRtfTableContainer {
+implements IRtfParagraphContainer, IRtfExternalGraphicContainer, IRtfTableContainer {
protected RtfAttributes m_attrib;
private RtfParagraph m_para;
private RtfExternalGraphic m_externalGraphic;
private RtfTable m_table;
RtfAfterBeforeBase(RtfSection parent, Writer w, RtfAttributes attrs) throws IOException {
- super((RtfContainer)parent,w,attrs);
+ super((RtfContainer)parent, w, attrs);
m_attrib = attrs;
}
public RtfParagraph newParagraph() throws IOException {
closeAll();
- m_para = new RtfParagraph(this,m_writer);
+ m_para = new RtfParagraph(this, m_writer);
return m_para;
}
public RtfParagraph newParagraph(RtfAttributes attrs) throws IOException {
closeAll();
- m_para = new RtfParagraph(this,m_writer,attrs);
+ m_para = new RtfParagraph(this, m_writer, attrs);
return m_para;
}
public RtfExternalGraphic newImage() throws IOException {
closeAll();
- m_externalGraphic = new RtfExternalGraphic(this,m_writer);
+ m_externalGraphic = new RtfExternalGraphic(this, m_writer);
return m_externalGraphic;
}
private void closeCurrentParagraph() throws IOException {
- if(m_para!=null) m_para.close();
+ if (m_para != null) {
+ m_para.close();
+ }
}
private void closeCurrentExternalGraphic() throws IOException {
- if(m_externalGraphic!=null) m_externalGraphic.close();
+ if (m_externalGraphic != null) {
+ m_externalGraphic.close();
+ }
}
private void closeCurrentTable() throws IOException {
- if(m_table != null) m_table.close();
+ if (m_table != null) {
+ m_table.close();
+ }
}
protected void writeRtfPrefix() throws IOException {
}
/** must be implemented to write the header or footer attributes */
- abstract protected void writeMyAttributes() throws IOException;
+ protected abstract void writeMyAttributes() throws IOException;
protected void writeRtfSuffix() throws IOException {
writeGroupMark(false);
}
- public RtfAttributes getAttributes(){
+ public RtfAttributes getAttributes() {
return m_attrib;
}
}
/** close current table if any and start a new one
- * @param tc added by Boris Poudérous on july 2002 in order to process number-columns-spanned attribute
+ * @param tc added by Boris Poudérous on july 2002 in order to process
+ * number-columns-spanned attribute
*/
public RtfTable newTable(RtfAttributes attrs, ITableColumnsInfo tc) throws IOException {
closeAll();
- m_table = new RtfTable(this,m_writer,attrs,tc);
+ m_table = new RtfTable(this, m_writer, attrs, tc);
return m_table;
}
/** close current table if any and start a new one */
public RtfTable newTable(ITableColumnsInfo tc) throws IOException {
closeAll();
- m_table = new RtfTable(this,m_writer,tc);
+ m_table = new RtfTable(this, m_writer, tc);
return m_table;
}
}
\ No newline at end of file
package org.apache.fop.rtf.rtflib.testdocs;
-import org.apache.fop.rtf.rtflib.rtfdoc.*;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfHyperLink;
+
import java.io.IOException;
/**
* @author <a href="mailto:mks@ANDREAS">Andreas Putz</a>
*/
-public class BasicLink extends TestDocument
-{
+public class BasicLink extends TestDocument {
//////////////////////////////////////////////////
// @@ Construction
//////////////////////////////////////////////////
/**
* Default constructor.
*/
- public BasicLink()
- {
+ public BasicLink() {
}
/** generate the body of the test document */
- protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws IOException
- {
+ protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws IOException {
RtfParagraph p = sect.newParagraph ();
p.newLineBreak();
p.newLineBreak();
public static final String TESTDOCS_PACKAGE = "org.apache.fop.rtf.rtflib.testdocs";
/** List of all TestDocument subclasses from this package */
- private final static String [] classNames = {
+ private static final String [] classNames = {
"SimpleDocument",
"TextAttributes",
"SimpleTable",
CreateTestDocuments(File outDir)
throws Exception {
- if(!outDir.isDirectory() || !outDir.canWrite()) {
+ if (!outDir.isDirectory() || !outDir.canWrite()) {
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 < classNames.length; i++) {
+ createOneTestDocument(classNames[i], outDir);
}
}
/** instantiate one TestDocument and let it generate its document */
- void createOneTestDocument(String className,File outDir)
+ void createOneTestDocument(String className, File outDir)
throws Exception {
className = TESTDOCS_PACKAGE + "." + className;
TestDocument td = null;
try {
td = (TestDocument)Class.forName(className).newInstance();
- } catch(Exception e) {
- throw new Exception("unable to instantiate '" + className + " as a TestDocument object: " + e);
+ } catch (Exception e) {
+ throw new Exception("unable to instantiate '" + className
+ + " as a TestDocument object: " + e);
}
td.setOutputDir(outDir);
td.generateOutput();
/** execute this to create test documents from all classes listed in classNames array */
public static void main(String args[])
throws Exception {
- if(args.length < 1) {
+ if (args.length < 1) {
System.err.println("usage: CreateTestDocuments <output directory>");
System.exit(1);
}
* @author bdelacretaz@codeconsult.ch
*/
-class DummyTableColumnsInfo implements ITableColumnsInfo
-{
+class DummyTableColumnsInfo implements ITableColumnsInfo {
public float getColumnWidth() {
return INVALID_COLUM_WIDTH;
*
* @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
*/
-class ExternalGraphic extends TestDocument
-{
+class ExternalGraphic extends TestDocument {
private String file = "file:///tmp/jfor-images/logo.";
//////////////////////////////////////////////////
/**
* Default constructor.
*/
- public ExternalGraphic ()
- {
+ public ExternalGraphic () {
}
/** generate the body of the test document */
- protected void generateDocument (RtfDocumentArea rda, RtfSection sect) throws IOException
- {
+ protected void generateDocument (RtfDocumentArea rda, RtfSection sect) throws IOException {
RtfParagraph p = sect.newParagraph ();
p.newLineBreak();
p.newLineBreak();
p.newLineBreak();
p.close();
- p = sect.newParagraph( );
+ p = sect.newParagraph();
p.newLineBreak();
p.newText ("PNG image with 150 % width");
p.newLineBreak();
p.newLineBreak();
p.close();
- p = sect.newParagraph( );
+ p = sect.newParagraph();
p.newLineBreak();
p.newLineBreak();
p.newText ("JPG image with width = 200px and height = 20 px");
p.newLineBreak();
p.close();
- p = sect.newParagraph( );
+ p = sect.newParagraph();
p.newLineBreak();
p.newLineBreak();
- p.newText ("GIF image with width = 200px and scaling = 'uniform', that means the image " +
- "size will adjusted automatically");
+ p.newText ("GIF image with width = 200px and scaling = 'uniform', that means the image "
+ + "size will adjusted automatically");
p.newLineBreak();
RtfExternalGraphic imageD = sect.newImage ();
imageD.setURL (file + "gif");
p.newLineBreak();
p.close();
- p = sect.newParagraph( );
+ p = sect.newParagraph();
p.newLineBreak();
p.newLineBreak();
p.newText ("GIF image");
package org.apache.fop.rtf.rtflib.testdocs;
-import java.util.Date;
-import java.io.*;
-import org.apache.fop.rtf.rtflib.rtfdoc.*;
+import java.io.IOException;
+
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfList;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfTable;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableRow;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableCell;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfListItem;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph;
/** Generates a simple RTF test document for the jfor rtflib package.
*/
-class ListInTable extends TestDocument
-{
+class ListInTable extends TestDocument {
/** generate the body of the test document */
- protected void generateDocument(RtfDocumentArea rda,RtfSection sect)
+ protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
throws IOException {
- sect.newParagraph().newText("There must be a table below where the second cell contains a bulleted list mixed with normal paragraphs");
+ sect.newParagraph().newText("There must be a table below where the "
+ + "second cell contains a bulleted list mixed with normal paragraphs");
final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo());
final RtfTableRow row = tbl.newTableRow();
row.newTableCell(RtfTableCell.DEFAULT_CELL_WIDTH).newParagraph().newText("cell A, simple");
final RtfTableCell c = row.newTableCell(RtfTableCell.DEFAULT_CELL_WIDTH);
- c.newParagraph().newText("cell B, contains this paragraph followed by a list and another paragraph");
- fillList(c.newList(null),1,3);
+ c.newParagraph().newText("cell B, contains this paragraph followed by "
+ + "a list and another paragraph");
+ fillList(c.newList(null), 1, 3);
c.newParagraph().newText("Normal paragraph, follows the list.");
row.newTableCell(RtfTableCell.DEFAULT_CELL_WIDTH).newParagraph().newText("cell C, simple");
}
- private void fillList(RtfList list,int listIndex,int nItems)
- throws IOException
- {
- for(int i=0; i < nItems; i++) {
+ private void fillList(RtfList list, int listIndex, int nItems)
+ throws IOException {
+ for (int i = 0; i < nItems; i++) {
final RtfListItem item = list.newListItem();
- for(int j=0; j <= i; j++) {
+ for (int j = 0; j <= i; j++) {
final RtfParagraph para = item.newParagraph();
para.newText("List " + listIndex + ", item " + i + ", paragraph " + j);
- if(i==0 && j==0) {
+ if (i == 0 && j == 0) {
final String txt = "This item takes more than one line to check word-wrapping.";
- para.newText(". " + "This list must have " + nItems + " items. " + txt + " " + txt + " " + txt);
+ para.newText(". " + "This list must have " + nItems
+ + " items. " + txt + " " + txt + " " + txt);
}
}
}
package org.apache.fop.rtf.rtflib.testdocs;
-import java.util.Date;
-import java.io.*;
-import org.apache.fop.rtf.rtflib.rtfdoc.*;
+import java.io.IOException;
+
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfTable;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableRow;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableCell;
/** Generates an RTF test document containing merged table cells
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
-class MergedTableCells extends TestDocument
-{
+class MergedTableCells extends TestDocument {
/** generate the body of the test document */
- protected void generateDocument(RtfDocumentArea rda,RtfSection sect)
+ protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
throws IOException {
sect.newParagraph().newText("This document contains a table with some merged cells.");
RtfTableRow r = tbl.newTableRow();
RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS);
c.setHMerge(c.MERGE_START);
- c.newParagraph().newText("cell 0,0, width 80mm, merge start, followed by two merged cells totalling 80mm width.");
+ c.newParagraph().newText("cell 0,0, width 80mm, merge start, "
+ + "followed by two merged cells totalling 80mm width.");
c = r.newTableCell(40 * MM_TO_TWIPS);
c.setHMerge(c.MERGE_WITH_PREVIOUS);
// fifth row, just one cell
{
RtfTableRow r = tbl.newTableRow();
- r.newTableCell(160 * MM_TO_TWIPS).newParagraph().newText("cell 4,0, width 160mm, only cell in this row");
+ r.newTableCell(160 * MM_TO_TWIPS).newParagraph().newText
+ ("cell 4,0, width 160mm, only cell in this row");
}
}
}
\ No newline at end of file
package org.apache.fop.rtf.rtflib.testdocs;
-import java.util.Date;
-import java.io.*;
-import org.apache.fop.rtf.rtflib.rtfdoc.*;
+import java.io.IOException;
+
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfTable;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableRow;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableCell;
+
/** Generates an RTF document to test nested tables with the jfor rtflib package.
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
private static final int MM_TO_TWIPS = (int)(1440f / 25.4f);
/** generate the body of the test document */
- protected void generateDocument(RtfDocumentArea rda,RtfSection sect)
+ protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
throws IOException {
- sect.newParagraph().newText("This document demonstrates pseudo-nested tables created using merged table cells");
+ sect.newParagraph().newText("This document demonstrates pseudo-nested "
+ + "tables created using merged table cells");
firstTestTable(sect);
RtfParagraph p = sect.newParagraph();
// second row contains nested table
{
RtfTableRow r = tbl.newTableRow();
- r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 1,0, width 40mm, to the left of nested table.");
+ r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText
+ ("cell 1,0, width 40mm, to the left of nested table.");
final RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS);
- c.newParagraph().newText("cell 1,1, width 80mm, this text is followed by a nested table in the same cell, followed by text that says 'AFTER NESTED TABLE'.");
- fillNestedTable(c.newTable(new DummyTableColumnsInfo()),1);
+ c.newParagraph().newText("cell 1,1, width 80mm, this text is "
+ + "followed by a nested table in the same cell, followed "
+ + "by text that says 'AFTER NESTED TABLE'.");
+ fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 1);
c.newParagraph().newText("AFTER NESTED TABLE");
- r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 1,2, width 40mm, to the right of nested table.");
+ r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText
+ ("cell 1,2, width 40mm, to the right of nested table.");
}
// third row, normal
{
RtfTableRow r = tbl.newTableRow();
- r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText("cell 2,0, width 80mm, this row has two cells.");
- r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText("cell 2,1, width 80mm, last cell.");
+ r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText
+ ("cell 2,0, width 80mm, this row has two cells.");
+ r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText
+ ("cell 2,1, width 80mm, last cell.");
}
}
{
RtfTableRow r = tbl.newTableRow();
RtfTableCell c = r.newTableCell(160 * MM_TO_TWIPS);
- c.newParagraph().newText("second test table: cell 0,0, width 160mm, only cell in this row.");
+ c.newParagraph().newText("second test table: cell 0,0, width 160mm, "
+ + "only cell in this row.");
}
// second row contains nested table
{
RtfTableRow r = tbl.newTableRow();
- r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 1,0, width 40mm, to the left of nested tables.");
+ r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText
+ ("cell 1,0, width 40mm, to the left of nested tables.");
final RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS);
- c.newParagraph().newText("cell 1,1, width 80mm, this text is followed by a nested table in the same cell, followed by text that says 'BETWEEN', then another table, then 'AFTER'.");
- fillNestedTable(c.newTable(new DummyTableColumnsInfo()),2);
+ c.newParagraph().newText("cell 1,1, width 80mm, this text is "
+ + "followed by a nested table in the same cell, followed "
+ + "by text that says 'BETWEEN', then another table, then 'AFTER'.");
+ fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 2);
c.newParagraph().newText("BETWEEN");
- fillNestedTable(c.newTable(new DummyTableColumnsInfo()),3);
+ fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 3);
c.newParagraph().newText("AFTER");
- r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 1,2, width 40mm, to the right of nested table.");
+ r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText
+ ("cell 1,2, width 40mm, to the right of nested table.");
}
// third row, normal
{
RtfTableRow r = tbl.newTableRow();
- r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText("cell 2,0, width 80mm, this row has two cells.");
- r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText("cell 2,1, width 80mm, last cell.");
+ r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText
+ ("cell 2,0, width 80mm, this row has two cells.");
+ r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText
+ ("cell 2,1, width 80mm, last cell.");
}
}
private void thirdTestTable(RtfSection sect)
throws IOException {
- sect.newParagraph().newText("Third test: table with two nested tables in cell 1,1 and one nested table in cell 0,1");
+ sect.newParagraph().newText("Third test: table with two nested tables "
+ + "in cell 1,1 and one nested table in cell 0,1");
final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo());
// first row, normal
{
RtfTableRow r = tbl.newTableRow();
RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS);
- c.newParagraph().newText("third test table: cell 0,0, width 40mm, the cell to its right contains a nested table with no other text.");
+ c.newParagraph().newText("third test table: cell 0,0, width 40mm, "
+ + "the cell to its right contains a nested table with no other text.");
c = r.newTableCell(80 * MM_TO_TWIPS);
- fillNestedTable(c.newTable(new DummyTableColumnsInfo()),4);
+ fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 4);
}
// second row contains nested table
{
RtfTableRow r = tbl.newTableRow();
- r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 1,0, width 40mm, to the left of nested tables.");
+ r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText
+ ("cell 1,0, width 40mm, to the left of nested tables.");
final RtfTableCell c = r.newTableCell(80 * MM_TO_TWIPS);
- c.newParagraph().newText("cell 1,1, width 80mm, this text is followed by a nested table in the same cell, followed by text that says 'BETWEEN', then another table, then 'AFTER'.");
- fillNestedTable(c.newTable(new DummyTableColumnsInfo()),5);
+ c.newParagraph().newText("cell 1,1, width 80mm, this text is "
+ + "followed by a nested table in the same cell, followed "
+ + "by text that says 'BETWEEN', then another table, then 'AFTER'.");
+ fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 5);
c.newParagraph().newText("BETWEEN");
- fillNestedTable(c.newTable(new DummyTableColumnsInfo()),6);
+ fillNestedTable(c.newTable(new DummyTableColumnsInfo()), 6);
c.newParagraph().newText("AFTER");
- r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText("cell 1,2, width 40mm, to the right of nested table.");
+ r.newTableCell(40 * MM_TO_TWIPS).newParagraph().newText
+ ("cell 1,2, width 40mm, to the right of nested table.");
}
// third row, normal
{
RtfTableRow r = tbl.newTableRow();
- r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText("cell 2,0, width 80mm, this row has two cells.");
- r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText("cell 2,1, width 80mm, last cell.");
+ r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText
+ ("cell 2,0, width 80mm, this row has two cells.");
+ r.newTableCell(80 * MM_TO_TWIPS).newParagraph().newText
+ ("cell 2,1, width 80mm, last cell.");
}
}
import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea;
import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection;
-import org.apache.fop.rtf.rtflib.rtfdoc.RtfExternalGraphic;
import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph;
import org.apache.fop.rtf.rtflib.rtfdoc.RtfText;
import org.apache.fop.rtf.rtflib.rtfdoc.RtfAttributes;
/** Generates a simple RTF test document for the jfor rtflib package.
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
-public class ParagraphAlignment extends TestDocument
-{
+public class ParagraphAlignment extends TestDocument {
- public ParagraphAlignment()
- {
+ public ParagraphAlignment() {
}
protected void generateDocument(RtfDocumentArea rda, RtfSection sect) throws java.io.IOException
{
package org.apache.fop.rtf.rtflib.testdocs;
-import java.util.Date;
-import java.io.*;
-import org.apache.fop.rtf.rtflib.rtfdoc.*;
+import java.io.IOException;
+
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph;
/** Generates a simple RTF test document for the jfor rtflib package.
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
class SimpleDocument
-extends TestDocument
-{
+extends TestDocument {
/** generate the body of the test document */
- protected void generateDocument(RtfDocumentArea rda,RtfSection sect)
+ protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
throws IOException {
sect.newParagraph().newText("First paragraph of the simple RTF test document.");
final RtfParagraph para = sect.newParagraph();
para.newText("Second paragraph of simple RTF test document.\n");
- for(int i=0; i < 242; i++) {
+ for (int i = 0; i < 242; i++) {
para.newText("This is string " + i);
para.newLineBreak();
}
package org.apache.fop.rtf.rtflib.testdocs;
-import java.util.Date;
-import java.io.*;
-import org.apache.fop.rtf.rtflib.rtfdoc.*;
+import java.io.IOException;
+
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfList;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfListItem;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph;
/** Generates a simple RTF test document for the jfor rtflib package.
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
-class SimpleLists extends TestDocument
-{
+class SimpleLists extends TestDocument {
/** generate the body of the test document */
- protected void generateDocument(RtfDocumentArea rda,RtfSection sect)
+ protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
throws IOException {
sect.newParagraph().newText("First paragraph of the 'SimpleLists' RTF test document.");
sect.newParagraph().newText("First bulleted list with 5 items.");
- makeList(sect,1,5,null);
+ makeList(sect, 1, 5, null);
sect.newParagraph().newText("Normal paragraph between lists 1 and 2.");
- makeList(sect,2,3,null);
+ makeList(sect, 2, 3, null);
sect.newParagraph().newText("Normal paragraph after list 2.");
sect.newParagraph().newText("Now a numbered list (4 items):");
final RtfList.NumberingStyle nn = new RtfList.NumberingStyle();
nn.isBulletedList = false;
- makeList(sect,3,4,nn);
+ makeList(sect, 3, 4, nn);
}
- private void makeList(RtfSection sect,int listIndex,int nItems,RtfList.NumberingStyle ns)
- throws IOException
- {
+ private void makeList(RtfSection sect, int listIndex, int nItems, RtfList.NumberingStyle ns)
+ throws IOException {
final RtfList list = sect.newList(null);
- if(ns != null) list.setNumberingStyle(ns);
- for(int i=0; i < nItems; i++) {
+ if (ns != null) {
+ list.setNumberingStyle(ns);
+ }
+ for (int i = 0; i < nItems; i++) {
final RtfListItem item = list.newListItem();
- for(int j=0; j <= i; j++) {
+ for (int j = 0; j <= i; j++) {
final RtfParagraph para = item.newParagraph();
para.newText("List " + listIndex + ", item " + i + ", paragraph " + j);
- if(i==0 && j==0) {
+ if (i == 0 && j == 0) {
final String txt = "This item takes more than one line to check word-wrapping.";
- para.newText(". " + "This list should have " + nItems + " items. " + txt + " " + txt + " " + txt);
+ para.newText(". " + "This list should have " + nItems
+ + " items. " + txt + " " + txt + " " + txt);
}
}
}
package org.apache.fop.rtf.rtflib.testdocs;
-import java.util.Date;
-import java.io.*;
-import org.apache.fop.rtf.rtflib.rtfdoc.*;
+import java.io.IOException;
+
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfTable;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableRow;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfTableCell;
/** Generates a simple RTF test document for the jfor rtflib package.
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
class SimpleTable extends TestDocument {
/** generate the body of the test document */
- protected void generateDocument(RtfDocumentArea rda,RtfSection sect)
+ protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
throws IOException {
final RtfTable tbl = sect.newTable(new DummyTableColumnsInfo());
final int MAX_ROW = 2;
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++) {
+ for (int row = 0; row < MAX_ROW; row++) {
final RtfTableRow r = tbl.newTableRow();
- for(int col=0; col < MAX_COL; col++) {
+ for (int col = 0; col < MAX_COL; col++) {
final float widthInInches = col / 2f + 1f;
final int widthInTwips = (int)(widthInInches * INCH_TO_TWIPS);
final RtfTableCell c = r.newTableCell(widthInTwips);
- c.newParagraph().newText("(" + row + "," + col + "), width " + widthInInches + "''");
- if(row==0 && col==1) {
- for(int i=0; i < 4; i++) {
+ c.newParagraph().newText("(" + row + "," + col + "), width "
+ + widthInInches + "''");
+ if (row == 0 && col == 1) {
+ for (int i = 0; i < 4; i++) {
c.newParagraph().newText("additional paragraph " + i + " of cell 0,1");
}
}
package org.apache.fop.rtf.rtflib.testdocs;
import java.util.Date;
-import java.io.*;
-import org.apache.fop.rtf.rtflib.rtfdoc.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.FileWriter;
+
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfFile;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph;
//import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;
/** Base class for generating RTF documents used to test the jfor rtflib package.
private File m_output;
final void setOutputDir(File outDir)
- throws IOException
- {
- m_output = new File(outDir,getRtfFilename());
+ throws IOException {
+ m_output = new File(outDir, getRtfFilename());
}
- final String getRtfFilename()
- {
+ final String getRtfFilename() {
// use class name for output filename
final String name = getClass().getName();
final int pos = name.lastIndexOf('.');
}
final void generateOutput()
- throws IOException
- {
+ throws IOException {
debugMsg("Generating document " + m_output + "...");
final RtfFile f = new RtfFile(new FileWriter(m_output));
final RtfDocumentArea rda = f.startDocumentArea();
final RtfSection sect = rda.newSection();
addIntroComments(sect);
- generateDocument(rda,sect);
+ generateDocument(rda, sect);
f.flush();
}
- protected abstract void generateDocument(RtfDocumentArea rda,RtfSection sect) throws IOException;
+ protected abstract void generateDocument(RtfDocumentArea rda, RtfSection sect)
+ throws IOException;
- void debugMsg(String msg)
- {
+ void debugMsg(String msg) {
System.err.println(msg);
}
- protected void addIntroComments(RtfSection sect) throws IOException
- {
+ protected void addIntroComments(RtfSection sect) throws IOException {
final RtfParagraph para = sect.newParagraph();
para.newText("jfor RTF library test document.");
package org.apache.fop.rtf.rtflib.testdocs;
-import java.util.Date;
-import java.io.*;
-import org.apache.fop.rtf.rtflib.rtfdoc.*;
+import java.io.IOException;
+
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfText;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfAttributes;
/** Generates a simple RTF test document for the jfor rtflib package.
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
-class TextAttributes extends TestDocument
-{
+class TextAttributes extends TestDocument {
/** generate the body of the test document */
- protected void generateDocument(RtfDocumentArea rda,RtfSection sect)
+ protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
throws IOException {
final RtfParagraph para = sect.newParagraph();
para.newText("This is normal\n");
- para.newText("This is bold\n",new RtfAttributes().set(RtfText.ATTR_BOLD));
- para.newText("This is italic\n",new RtfAttributes().set(RtfText.ATTR_ITALIC));
- para.newText("This is underline\n",new RtfAttributes().set(RtfText.ATTR_UNDERLINE));
+ para.newText("This is bold\n", new RtfAttributes().set(RtfText.ATTR_BOLD));
+ para.newText("This is italic\n", new RtfAttributes().set(RtfText.ATTR_ITALIC));
+ para.newText("This is underline\n", new RtfAttributes().set(RtfText.ATTR_UNDERLINE));
// RTF font sizes are in half-points
- para.newText("This is size 48\n",new RtfAttributes().set(RtfText.ATTR_FONT_SIZE,96));
+ para.newText("This is size 48\n", new RtfAttributes().set(RtfText.ATTR_FONT_SIZE, 96));
para.newText(
"This is bold and italic\n",
final RtfAttributes attr = new RtfAttributes();
attr.set(RtfText.ATTR_BOLD).set(RtfText.ATTR_ITALIC);
attr.set(RtfText.ATTR_UNDERLINE);
- attr.set(RtfText.ATTR_FONT_SIZE,72);
- para.newText("This is bold, italic, underline and size 36\n",attr);
+ attr.set(RtfText.ATTR_FONT_SIZE, 72);
+ para.newText("This is bold, italic, underline and size 36\n", attr);
para.newText("This is back to normal\n");
}
package org.apache.fop.rtf.rtflib.testdocs;
-import java.util.Date;
-import java.io.*;
-import org.apache.fop.rtf.rtflib.rtfdoc.*;
+import java.io.IOException;
+
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfDocumentArea;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfSection;
+import org.apache.fop.rtf.rtflib.rtfdoc.RtfParagraph;
/** Generates an RTF document to test the WhitespaceCollapser
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
-class Whitespace extends TestDocument
-{
+class Whitespace extends TestDocument {
/** generate the body of the test document */
- protected void generateDocument(RtfDocumentArea rda,RtfSection sect)
+ protected void generateDocument(RtfDocumentArea rda, RtfSection sect)
throws IOException {
final RtfParagraph p1 = sect.newParagraph();
- p1.newText("\t Each word of this paragraph must be separated\tfrom\t\n\tthe next word with exactly\t \tone");
+ p1.newText("\t Each word of this paragraph must be "
+ + "separated\tfrom\t\n\tthe next word with exactly\t \tone");
p1.newText(" space.");
final RtfParagraph p2 = sect.newParagraph();
p2.newText(" there must\tbe \t");
p2.newText("exactly");
p2.newText(" one space ");
- p2.newText("between each\tword and the next, and no spaces at the beginning or end of the paragraph.");
+ p2.newText("between each\tword and the next, and no spaces at the "
+ + "beginning or end of the paragraph.");
final RtfParagraph p3 = sect.newParagraph();
p3.newText("The word 'boomerang' must be written after this with no funny spacing: ");
* @author a.putz@skynamics.com (Andreas Putz)
*/
-public class ImageConstants
-{
+public class ImageConstants {
//////////////////////////////////////////////////
// @@ Symbolic constants
//////////////////////////////////////////////////
/** Defines the file extensions and the RTF property belongs to */
public static Hashtable SUPPORTED_IMAGE_TYPES = new Hashtable ();
- static
- {
+ static {
SUPPORTED_IMAGE_TYPES.put (EMF_EXT, new Integer (I_EMF));
SUPPORTED_IMAGE_TYPES.put (PNG_EXT, new Integer (I_PNG));
SUPPORTED_IMAGE_TYPES.put (JPG_EXT, new Integer (I_JPG_C));
- SUPPORTED_IMAGE_TYPES.put (JPEG_EXT,new Integer (I_JPG_C));
+ SUPPORTED_IMAGE_TYPES.put (JPEG_EXT, new Integer (I_JPG_C));
SUPPORTED_IMAGE_TYPES.put (GIF_EXT, new Integer (I_GIF));
}
/**
* Private constructor.
*/
- private ImageConstants()
- {
+ private ImageConstants() {
}
}
* This class belongs to the <fo:external-graphic> tag processing.
* @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
*/
-public class ImageUtil
-{
+public class ImageUtil {
//////////////////////////////////////////////////
// @@ Construction
/**
* Private constructor.
*/
- private ImageUtil ()
- {
+ private ImageUtil () {
}
* -1 There is no digit\n
* number The digits as integer
*/
- public static int getInt (String value)
- {
+ public static int getInt (String value) {
String retString = new String ();
StringBuffer s = new StringBuffer (value);
int len = s.length ();
- for (int i = 0; i < len; i++)
- {
- if (Character.isDigit (s.charAt (i)))
- {
+ for (int i = 0; i < len; i++) {
+ if (Character.isDigit (s.charAt (i))) {
retString += s.charAt (i);
}
}
- if (retString.length () == 0)
- {
+ if (retString.length () == 0) {
return -1;
- }
- else
- {
+ } else {
return Integer.parseInt (retString);
}
}
* true The string contains a % value
* false Other string
*/
- public static boolean isPercent (String value)
- {
- if (value.endsWith ("%"))
- {
+ public static boolean isPercent (String value) {
+ if (value.endsWith ("%")) {
return true;
}
* false If different
*/
public static boolean compareHexValues (byte[] pattern, byte[] data, int searchAt,
- boolean searchForward)
- {
- if (searchAt >= data.length)
- {
+ boolean searchForward) {
+ if (searchAt >= data.length) {
return false;
}
int pLen = pattern.length;
- if (searchForward)
- {
- if (pLen >= (data.length - searchAt))
- {
+ if (searchForward) {
+ if (pLen >= (data.length - searchAt)) {
return false;
}
- for (int i = 0; i < pLen; i++)
- {
- if (pattern[i] != data[searchAt + i])
- {
+ for (int i = 0; i < pLen; i++) {
+ if (pattern[i] != data[searchAt + i]) {
return false;
}
}
return true;
- }
- else
- {
- if (pLen > (searchAt + 1))
- {
+ } else {
+ if (pLen > (searchAt + 1)) {
return false;
}
- for (int i = 0; i < pLen; i++)
- {
- if (pattern[pLen - i - 1] != data[searchAt - i])
- {
+ for (int i = 0; i < pLen; i++) {
+ if (pattern[pLen - i - 1] != data[searchAt - i]) {
return false;
}
}
* @return A number
*/
public static int getIntFromByteArray (byte[] data, int startAt, int length,
- boolean searchForward)
- {
+ boolean searchForward) {
int bit = 8;
int bitMoving = length * bit;
int retVal = 0;
- if (startAt >= data.length)
- {
+ if (startAt >= data.length) {
return retVal;
}
- if (searchForward)
- {
- if (length >= (data.length - startAt))
- {
+ if (searchForward) {
+ if (length >= (data.length - startAt)) {
return retVal;
}
- for (int i = 0; i < length; i++)
- {
+ for (int i = 0; i < length; i++) {
bitMoving -= bit;
int iData = (int) data[startAt + i];
- if (iData < 0)
+ if (iData < 0) {
iData += 256;
+ }
retVal += iData << bitMoving;
}
- }
- else
- {
- if (length > (startAt + 1))
- {
+ } else {
+ if (length > (startAt + 1)) {
return retVal;
}
- for (int i = 0; i < length; i++)
- {
+ for (int i = 0; i < length; i++) {
bitMoving -= bit;
int iData = (int) data[startAt - i];
- if (iData < 0)
+ if (iData < 0) {
iData += 256;
+ }
retVal += iData << bitMoving; }
}