package org.apache.fop.rtf.rtflib.rtfdoc;
-import java.util.*;
+import java.util.HashMap;
+import java.util.Iterator;
import org.xml.sax.Attributes;
import org.xml.sax.helpers.AttributesImpl;
*/
public class RtfAttributes
-implements java.lang.Cloneable
-{
+implements java.lang.Cloneable {
private HashMap m_values = new HashMap();
/** set attributes from a other attributes object.
* @return this object, for chaining calls
*/
- public RtfAttributes set (RtfAttributes attrs)
- {
- if (attrs != null)
- {
+ public RtfAttributes set (RtfAttributes attrs) {
+ if (attrs != null) {
Iterator it = attrs.nameIterator ();
- while (it.hasNext ())
- {
+ while (it.hasNext ()) {
String name = (String) it.next ();
- if (attrs.getValue(name) instanceof Integer){
+ if (attrs.getValue(name) instanceof Integer) {
Integer value = (Integer)attrs.getValue (name);
- if (value == null)
+ if (value == null) {
set (name);
- else
+ } else {
set (name, value.intValue ());
- }
- else if(attrs.getValue(name) instanceof String){
+ }
+ } else if (attrs.getValue(name) instanceof String) {
String value = (String)attrs.getValue (name);
- if (value == null)
+ if (value == null) {
set (name);
- else
+ } else {
set (name, value);
- }else{
+ }
+ } else {
set (name);
}
}
// indicate the XSL attributes used to build the Rtf attributes
- setXslAttributes( attrs.getXslAttributes() );
+ setXslAttributes(attrs.getXslAttributes());
}
return this;
}
/** set an attribute that has no value.
* @return this object, for chaining calls
*/
- public RtfAttributes set(String name)
- {
- m_values.put(name,null);
+ public RtfAttributes set(String name) {
+ m_values.put(name, null);
return this;
}
/** unset an attribute that has no value
* @return this object, for chaining calls
*/
- public RtfAttributes unset(String name)
- {
+ public RtfAttributes unset(String name) {
m_values.remove(name);
return this;
}
/** debugging log */
- public String toString()
- {
+ public String toString() {
return m_values.toString() + "(" + super.toString() + ")";
}
/** implement cloning */
- public Object clone()
- {
+ public Object clone() {
final RtfAttributes result = new RtfAttributes();
result.m_values = (HashMap)m_values.clone();
// Added by Normand Masse
// indicate the XSL attributes used to build the Rtf attributes
- if ( m_xsl_attributes != null ) {
- result.m_xsl_attributes = new org.xml.sax.helpers.AttributesImpl( m_xsl_attributes );
+ if (m_xsl_attributes != null) {
+ result.m_xsl_attributes = new org.xml.sax.helpers.AttributesImpl(m_xsl_attributes);
}
return result;
/** set an attribute that has an integer value
* @return this object, for chaining calls
*/
- public RtfAttributes set(String name,int value)
- {
- m_values.put(name,new Integer(value));
+ public RtfAttributes set(String name, int value) {
+ m_values.put(name, new Integer(value));
return this;
}
- public RtfAttributes set(String name, String type)
- {
- m_values.put(name,type);
+ public RtfAttributes set(String name, String type) {
+ m_values.put(name, type);
return this;
}
/** get the value of an attribute, null if not found */
- public Object getValue(String name)
- {
+ public Object getValue(String name) {
return m_values.get(name);
}
/** true if given attribute is set */
- public boolean isSet(String name)
- {
+ public boolean isSet(String name) {
return m_values.containsKey(name);
}
/** return an Iterator on all names that are set */
- public Iterator nameIterator()
- {
+ public Iterator nameIterator() {
return m_values.keySet().iterator();
}
// Added by Normand Masse
// Used for attribute inheritance
- public void setXslAttributes( Attributes pAttribs ) {
- if ( pAttribs == null ) {
+ public void setXslAttributes(Attributes pAttribs) {
+ if (pAttribs == null) {
return;
}
// copy/replace the xsl attributes into the current attributes
- if ( m_xsl_attributes != null ) {
- for ( int i = 0; i < pAttribs.getLength(); i++ ) {
- String wKey = pAttribs.getQName( i );
- int wPos = m_xsl_attributes.getIndex( wKey );
- if ( wPos == -1 ) {
- ((AttributesImpl)m_xsl_attributes).addAttribute( pAttribs.getURI( i ),
+ if (m_xsl_attributes != null) {
+ for (int i = 0; i < pAttribs.getLength(); i++) {
+ String wKey = pAttribs.getQName(i);
+ int wPos = m_xsl_attributes.getIndex(wKey);
+ if (wPos == -1) {
+ ((AttributesImpl)m_xsl_attributes).addAttribute(pAttribs.getURI(i),
pAttribs.getLocalName(i), pAttribs.getQName(i),
pAttribs.getType(i), pAttribs.getValue(i));
} else {
- ((AttributesImpl)m_xsl_attributes).setAttribute( wPos, pAttribs.getURI( i ),
+ ((AttributesImpl)m_xsl_attributes).setAttribute(wPos, pAttribs.getURI(i),
pAttribs.getLocalName(i), pAttribs.getQName(i),
pAttribs.getType(i), pAttribs.getValue(i));
}
}
} else {
- m_xsl_attributes = new org.xml.sax.helpers.AttributesImpl( pAttribs );
+ m_xsl_attributes = new org.xml.sax.helpers.AttributesImpl(pAttribs);
}
}
}
/** The opposite of RtfAfter */
public class RtfBefore extends RtfAfterBeforeBase {
/**RtfBefore attributes*/
- public final static String HEADER = "header";
+ public static final String HEADER = "header";
- public final static String[] HEADER_ATTR = new String[]{
+ public static final String[] HEADER_ATTR = new String[]{
HEADER
};
RtfBefore(RtfSection parent, Writer w, RtfAttributes attrs) throws IOException {
- super(parent,w,attrs);
+ super(parent, w, attrs);
}
protected void writeMyAttributes() throws IOException {
- writeAttributes(m_attrib,HEADER_ATTR);
+ writeAttributes(m_attrib, HEADER_ATTR);
}
}
\ No newline at end of file
* This class belongs to the "id" attribute processing.
* @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
*/
-public class RtfBookmark extends RtfElement
-{
+public class RtfBookmark extends RtfElement {
//////////////////////////////////////////////////
// @@ Members
//////////////////////////////////////////////////
* @param writer a <code>Writer</code> value
* @param bookmark Name of the bookmark
*/
- RtfBookmark (IRtfBookmarkContainer parent, Writer w, String bookmark) throws IOException
- {
+ RtfBookmark (IRtfBookmarkContainer parent, Writer w, String bookmark) throws IOException {
super ((RtfContainer) parent, w);
int now = bookmark.length ();
this.bookmark = bookmark.substring (0, now < maxBookmarkLength ? now : maxBookmarkLength);
- this.bookmark = this.bookmark.replace ('.',replaceCharacter);
- this.bookmark = this.bookmark.replace (' ',replaceCharacter);
+ this.bookmark = this.bookmark.replace ('.', replaceCharacter);
+ this.bookmark = this.bookmark.replace (' ', replaceCharacter);
}
*
* @throws IOException On Error
*/
- public void writeRtfPrefix () throws IOException
- {
+ public void writeRtfPrefix () throws IOException {
startBookmark ();
}
*
* @exception IOException On error
*/
- public void writeRtfContent () throws IOException
- {
+ public void writeRtfContent () throws IOException {
// this.getRtfFile ().getLog ().logInfo ("Write bookmark '" + bookmark + "'.");
// No content to write
}
*
* @throws IOException On Error
*/
- public void writeRtfSuffix () throws IOException
- {
+ public void writeRtfSuffix () throws IOException {
endBookmark ();
}
*
* @throws IOException On error
*/
- private void startBookmark () throws IOException
- {
+ private void startBookmark () throws IOException {
// {\*\bkmkstart test}
writeRtfBookmark ("bkmkstart");
*
* @throws IOException On error
*/
- private void endBookmark () throws IOException
- {
+ private void endBookmark () throws IOException {
// {\*\bkmkend test}
writeRtfBookmark ("bkmkend");
*
* @throws IOException On error
*/
- private void writeRtfBookmark (String tag) throws IOException
- {
- if (bookmark == null)
- {
+ private void writeRtfBookmark (String tag) throws IOException {
+ if (bookmark == null) {
return;
}
}
/** true if this element would generate no "useful" RTF content */
- public boolean isEmpty()
- {
- return bookmark==null || bookmark.trim().length() == 0;
+ public boolean isEmpty() {
+ return bookmark == null || bookmark.trim().length() == 0;
}
}
* implemented as stand alone.
* @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
*/
-public class RtfBookmarkContainerImpl extends RtfContainer implements IRtfBookmarkContainer
-{
+public class RtfBookmarkContainerImpl extends RtfContainer implements IRtfBookmarkContainer {
//////////////////////////////////////////////////
// @@ Members
//////////////////////////////////////////////////
*
* @exception IOException On error
*/
- RtfBookmarkContainerImpl (RtfContainer parent, Writer w) throws IOException
- {
+ RtfBookmarkContainerImpl (RtfContainer parent, Writer w) throws IOException {
super (parent, w, null);
}
*
* @throws IOException On eror
*/
- public RtfBookmark newBookmark (String bookmark) throws IOException
- {
- if (mBookmark != null)
- {
+ public RtfBookmark newBookmark (String bookmark) throws IOException {
+ if (mBookmark != null) {
mBookmark.close ();
}
import java.util.Vector;
import java.util.Hashtable;
-import java.awt.Color;
import java.io.IOException;
/**
* @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
*/
-public class RtfColorTable
-{
+public class RtfColorTable {
//////////////////////////////////////////////////
// @@ Symbolic constants
//////////////////////////////////////////////////
/**
* Constructor.
*/
- private RtfColorTable ()
- {
+ private RtfColorTable () {
colorTable = new Vector ();
colorIndex = new Hashtable ();
namedColors = new Hashtable ();
*
* @return The instance of RTFColorTable
*/
- public static RtfColorTable getInstance ()
- {
- if (instance == null)
- {
+ public static RtfColorTable getInstance () {
+ if (instance == null) {
instance = new RtfColorTable ();
}
/**
* Initialize the color table.
*/
- private void init ()
- {
- addNamedColor("black",getColorNumber (0, 0, 0));
- addNamedColor("white",getColorNumber (255, 255, 255));
- addNamedColor("red",getColorNumber (255, 0, 0));
- addNamedColor("green",getColorNumber (0, 255, 0));
- addNamedColor("blue",getColorNumber (0, 0, 255));
- addNamedColor("cyan",getColorNumber (0, 255, 255));
- addNamedColor("magenta",getColorNumber (255, 0, 255));
- addNamedColor("yellow",getColorNumber (255, 255, 0));
+ private void init () {
+ addNamedColor("black", getColorNumber (0, 0, 0));
+ addNamedColor("white", getColorNumber (255, 255, 255));
+ addNamedColor("red", getColorNumber (255, 0, 0));
+ addNamedColor("green", getColorNumber (0, 255, 0));
+ addNamedColor("blue", getColorNumber (0, 0, 255));
+ addNamedColor("cyan", getColorNumber (0, 255, 255));
+ addNamedColor("magenta", getColorNumber (255, 0, 255));
+ addNamedColor("yellow", getColorNumber (255, 255, 0));
getColorNumber (0, 0, 128);
getColorNumber (0, 128, 128);
// Added by Normand Masse
// Gray color added
- addNamedColor( "gray", getColorNumber( 128, 128, 128 ) );
+ addNamedColor("gray", getColorNumber(128, 128, 128));
getColorNumber (192, 192, 192);
}
/** define a named color for getColorNumber(String) */
- private void addNamedColor(String name,int colorNumber)
- {
- namedColors.put(name.toLowerCase(),new Integer(colorNumber));
+ private void addNamedColor(String name, int colorNumber) {
+ namedColors.put(name.toLowerCase(), new Integer(colorNumber));
}
//////////////////////////////////////////////////
/** get the RTF number of a named color
* @return null if name not found
*/
- public Integer getColorNumber (String name)
- {
+ public Integer getColorNumber (String name) {
return (Integer)namedColors.get(name.toLowerCase());
}
*
* @return The number of the color in the table
*/
- public int getColorNumber (int red, int green, int blue)
- {
+ public int getColorNumber (int red, int green, int blue) {
Integer identifier = new Integer (determineIdentifier (red, green, blue));
Object o = colorIndex.get (identifier);
int retVal;
- if (o == null)
- {
+ if (o == null) {
addColor (identifier);
retVal = colorTable.size ();
- }
- else
- {
+ } else {
retVal = ((Integer) o).intValue ();
}
*
* @throws IOException On error
*/
- public void writeColors (RtfHeader header) throws IOException
- {
- if (colorTable == null || colorTable.size () == 0)
- {
+ public void writeColors (RtfHeader header) throws IOException {
+ if (colorTable == null || colorTable.size () == 0) {
return;
}
int len = colorTable.size ();
- for (int i = 0; i < len; i++)
- {
+ for (int i = 0; i < len; i++) {
int identifier = ((Integer) colorTable.get (i)).intValue ();
header.write ("\\red" + determineColorLevel (identifier, RED));
*
* @param i Identifier of color
*/
- private void addColor (Integer i)
- {
+ private void addColor (Integer i) {
colorIndex.put (i, new Integer (colorTable.size () + 1));
colorTable.addElement (i);
}
*
* @return Unique identifier of color
*/
- private int determineIdentifier (int red, int green, int blue)
- {
+ private int determineIdentifier (int red, int green, int blue) {
int c = red << RED;
c += green << GREEN;
*
* @return Color level in byte size
*/
- private int determineColorLevel (int identifier, int color)
- {
+ private int determineColorLevel (int identifier, int color) {
int retVal = (byte) (identifier >> color);
return retVal < 0 ? retVal + 256 : retVal;
package org.apache.fop.rtf.rtflib.rtfdoc;
import java.io.Writer;
-import java.util.*;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Iterator;
import java.io.IOException;
import org.apache.fop.rtf.rtflib.exceptions.RtfStructureException;
/** Create an RTF container as a child of given container */
RtfContainer(RtfContainer parent, Writer w) throws IOException {
- this(parent,w,null);
+ this(parent, w, null);
}
/** Create an RTF container as a child of given container with given attributes */
- RtfContainer(RtfContainer parent, Writer w,RtfAttributes attr) throws IOException {
- super(parent,w,attr);
+ RtfContainer(RtfContainer parent, Writer w, RtfAttributes attr) throws IOException {
+ super(parent, w, attr);
m_children = new LinkedList();
}
/** add a child element to this */
protected void addChild(RtfElement e)
throws RtfStructureException {
- if(isClosed()) {
+ if (isClosed()) {
// No childs should be added to a container that has been closed
final StringBuffer sb = new StringBuffer();
sb.append("addChild: container already closed (parent=");
* Add by Boris Poudérous on 07/22/2002
* Set the children list
*/
- public boolean setChildren (List children)
- {
- if (children instanceof LinkedList)
- {
+ public boolean setChildren (List children) {
+ if (children instanceof LinkedList) {
this.m_children = (LinkedList)children;
return true;
}
/** write RTF code of all our children */
protected void writeRtfContent()
throws IOException {
- for(Iterator it = m_children.iterator(); it.hasNext(); ) {
+ for (Iterator it = m_children.iterator(); it.hasNext();) {
final RtfElement e = (RtfElement)it.next();
e.writeRtf();
}
/** true if this (recursively) contains at least one RtfText object */
boolean containsText() {
boolean result = false;
- for(Iterator it = m_children.iterator(); it.hasNext(); ) {
+ for (Iterator it = m_children.iterator(); it.hasNext();) {
final RtfElement e = (RtfElement)it.next();
- if(e instanceof RtfText) {
+ if (e instanceof RtfText) {
result = !e.isEmpty();
- } else if(e instanceof RtfContainer) {
- if(((RtfContainer)e).containsText()) {
+ } else if (e instanceof RtfContainer) {
+ if (((RtfContainer)e).containsText()) {
result = true;
}
}
- if(result) break;
+ if (result) {
+ break;
+ }
}
return result;
}
/** debugging to given Writer */
- void dump(Writer w,int indent)
+ void dump(Writer w, int indent)
throws IOException {
- super.dump(w,indent);
- for(Iterator it = m_children.iterator(); it.hasNext(); ) {
+ super.dump(w, indent);
+ for (Iterator it = m_children.iterator(); it.hasNext();) {
final RtfElement e = (RtfElement)it.next();
- e.dump(w,indent + 1);
+ e.dump(w, indent + 1);
}
}
/** don't write any RTF if empty of if our options block it */
protected boolean okToWriteRtf() {
boolean result = super.okToWriteRtf() && !isEmpty();
- if(result && !m_options.renderContainer(this)) {
+ if (result && !m_options.renderContainer(this)) {
result = false;
}
return result;
/** true if this element would generate no "useful" RTF content.
* For an RtfContainer, true if it has no children where isEmpty() is false
*/
- public boolean isEmpty()
- {
+ public boolean isEmpty() {
boolean result = true;
- for(Iterator it = m_children.iterator(); it.hasNext(); ) {
+ for (Iterator it = m_children.iterator(); it.hasNext();) {
final RtfElement e = (RtfElement)it.next();
- if(!e.isEmpty()) {
+ if (!e.isEmpty()) {
result = false;
break;
}
*/
public class RtfDocumentArea
-extends RtfContainer
-{
+extends RtfContainer {
private RtfSection m_currentSection;
/** Create an RTF element as a child of given container */
- RtfDocumentArea(RtfFile f,Writer w) throws IOException
- {
- super(f,w);
+ RtfDocumentArea(RtfFile f, Writer w) throws IOException {
+ super(f, w);
}
/** close current RtfSection if any and create a new one */
- public RtfSection newSection() throws IOException
- {
- if(m_currentSection != null) m_currentSection.close();
- m_currentSection = new RtfSection(this,m_writer);
+ public RtfSection newSection() throws IOException {
+ if (m_currentSection != null) {
+ m_currentSection.close();
+ }
+ m_currentSection = new RtfSection(this, m_writer);
return m_currentSection;
}
}
\ No newline at end of file
package org.apache.fop.rtf.rtflib.rtfdoc;
-import java.io.*;
-import java.util.*;
+import java.io.Writer;
+import java.io.IOException;
+import java.util.Iterator;
//import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;
-import org.xml.sax.Attributes;
/** Base class for all elements of an RTF file.
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
private static int m_idCounter;
/** Create an RTF element as a child of given container */
- RtfElement(RtfContainer parent,Writer w) throws IOException {
- this(parent,w,null);
+ RtfElement(RtfContainer parent, Writer w) throws IOException {
+ this(parent, w, null);
}
/** Create an RTF element as a child of given container with given attributes */
- RtfElement(RtfContainer parent,Writer w,RtfAttributes attr) throws IOException {
+ RtfElement(RtfContainer parent, Writer w, RtfAttributes attr) throws IOException {
m_id = m_idCounter++;
m_parent = parent;
m_attrib = (attr != null ? attr : new RtfAttributes());
- if(m_parent != null) m_parent.addChild(this);
+ if (m_parent != null) {
+ m_parent.addChild(this);
+ }
m_writer = w;
m_written = false;
}
/** write the RTF code of this element to our Writer */
public final void writeRtf() throws IOException {
- if(!m_written) {
+ if (!m_written) {
m_written = true;
- if(okToWriteRtf()) {
+ if (okToWriteRtf()) {
writeRtfPrefix();
writeRtfContent();
writeRtfSuffix();
/** write given attribute values to our Writer
* @param nameList if given, only attribute names from this list are considered
*/
- protected void writeAttributes(RtfAttributes attr,String [] nameList)
+ protected void writeAttributes(RtfAttributes attr, String [] nameList)
throws IOException {
- if(attr==null) return;
+ if (attr == null) {
+ return;
+ }
- if(nameList != null) {
+ if (nameList != null) {
// process only given attribute names
- for(int i=0; i < nameList.length; i++) {
+ for (int i = 0; i < nameList.length; i++) {
final String name = nameList[i];
- if(attr.isSet(name)) {
- writeOneAttribute(name,attr.getValue(name));
+ if (attr.isSet(name)) {
+ writeOneAttribute(name, attr.getValue(name));
}
}
} else {
// process all defined attributes
- for(Iterator it = attr.nameIterator(); it.hasNext(); ) {
+ for (Iterator it = attr.nameIterator(); it.hasNext();) {
final String name = (String)it.next();
- if(attr.isSet(name)) {
- writeOneAttribute(name,attr.getValue(name));
+ if (attr.isSet(name)) {
+ writeOneAttribute(name, attr.getValue(name));
}
}
}
}
/** write one attribute to our Writer */
- protected void writeOneAttribute(String name,Object value)
+ protected void writeOneAttribute(String name, Object value)
throws IOException {
String cw = name;
- if(value instanceof Integer) {
+ if (value instanceof Integer) {
// attribute has integer value, must write control word + value
cw += value;
- }else if(value instanceof String){
+ } else if (value instanceof String) {
cw += value;
}
writeControlWord(cw);
}
/** write one attribute to our Writer without a space*/
- protected void writeOneAttributeNS(String name,Object value)
+ protected void writeOneAttributeNS(String name, Object value)
throws IOException {
String cw = name;
- if(value instanceof Integer) {
+ if (value instanceof Integer) {
// attribute has integer value, must write control word + value
cw += value;
- }else if(value instanceof String){
+ } else if (value instanceof String) {
cw += value;
}
writeControlWordNS(cw);
}
/** debugging to given PrintWriter */
- void dump(Writer w,int indent)
+ void dump(Writer w, int indent)
throws IOException {
- for(int i=0; i < indent; i++) {
+ for (int i = 0; i < indent; i++) {
w.write(' ');
}
w.write(this.toString());
RtfFile getRtfFile() {
// go up the chain of parents until we find the topmost one
RtfElement result = this;
- while(result.m_parent != null) {
+ while (result.m_parent != null) {
result = result.m_parent;
}
/** find the first parent where c.isAssignableFrom(parent.getClass()) is true
* @return null if not found
*/
- RtfElement getParentOfClass(Class c)
- {
+ RtfElement getParentOfClass(Class c) {
RtfElement result = null;
RtfElement current = this;
- while(current.m_parent != null) {
+ while (current.m_parent != null) {
current = current.m_parent;
- if(c.isAssignableFrom(current.getClass())) {
+ if (c.isAssignableFrom(current.getClass())) {
result = current;
break;
}
// make the exception message stand out so that the problem is visible
writeControlWord("fs48");
-// RtfStringConverter.getInstance().writeRtfString(m_writer,JForVersionInfo.getShortVersionInfo() + ": ");
- RtfStringConverter.getInstance().writeRtfString(m_writer,ie.getClass().getName());
+// RtfStringConverter.getInstance().writeRtfString(m_writer,
+// JForVersionInfo.getShortVersionInfo() + ": ");
+ RtfStringConverter.getInstance().writeRtfString(m_writer, ie.getClass().getName());
writeControlWord("fs20");
- RtfStringConverter.getInstance().writeRtfString(m_writer," " + ie.toString());
+ RtfStringConverter.getInstance().writeRtfString(m_writer, " " + ie.toString());
writeControlWord("par");
writeGroupMark(false);
package org.apache.fop.rtf.rtflib.rtfdoc;
-import org.apache.fop.rtf.rtflib.rtfdoc.RtfElement;
-import org.apache.fop.rtf.rtflib.rtfdoc.RtfContainer;
-import org.apache.fop.rtf.rtflib.rtfdoc.RtfAttributes;
-
import org.apache.fop.rtf.rtflib.tools.ImageConstants;
import org.apache.fop.rtf.rtflib.tools.ImageUtil;
//import org.apache.fop.rtf.rtflib.tools.jpeg.Encoder;
//import org.apache.fop.rtf.rtflib.tools.jpeg.JPEGException;
import java.io.BufferedInputStream;
-import java.io.BufferedOutputStream;
-import java.io.InputStreamReader;
import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
import java.io.IOException;
import java.io.Writer;
import java.io.File;
import java.net.URL;
import java.net.MalformedURLException;
-import java.util.Hashtable;
/**
* Creates an RTF image from an external graphic file.
* @author Gianugo Rabellino gianugo@rabellino.it
*/
-public class RtfExternalGraphic extends RtfElement
-{
+public class RtfExternalGraphic extends RtfElement {
/** Exception thrown when an image file/URL cannot be read */
- public static class ExternalGraphicException extends IOException
- {
- ExternalGraphicException(String reason)
- {
+ public static class ExternalGraphicException extends IOException {
+ ExternalGraphicException(String reason) {
super(reason);
}
}
protected void writeRtfContent() throws IOException {
try {
writeRtfContentWithException();
- } catch(ExternalGraphicException ie) {
+ } catch (ExternalGraphicException ie) {
writeExceptionInRtf(ie);
}
}
if (url == null) {
- throw new ExternalGraphicException("The attribute 'url' of <fo:external-graphic> is null.");
+ throw new ExternalGraphicException("The attribute 'url' of "
+ + "<fo:external-graphic> is null.");
}
- String linkToRoot = System.getProperty( "jfor_link_to_root" );
- if (linkToRoot != null)
- {
- m_writer.write( "{\\field {\\* \\fldinst { INCLUDEPICTURE \"" );
- m_writer.write( linkToRoot );
- File urlFile = new File( url.getFile() );
- m_writer.write( urlFile.getName() );
- m_writer.write( "\" \\\\* MERGEFORMAT \\\\d }}}" );
+ String linkToRoot = System.getProperty("jfor_link_to_root");
+ if (linkToRoot != null) {
+ m_writer.write("{\\field {\\* \\fldinst { INCLUDEPICTURE \"");
+ m_writer.write(linkToRoot);
+ File urlFile = new File(url.getFile());
+ m_writer.write(urlFile.getName());
+ m_writer.write("\" \\\\* MERGEFORMAT \\\\d }}}");
return;
}
byte[] data = null;
- try
- {
- // image reading patch provided by Michael Krause <michakurt@web.de>
- final BufferedInputStream bin = new BufferedInputStream(url.openStream());
- final ByteArrayOutputStream bout = new ByteArrayOutputStream();
- while (true) {
- final int datum = bin.read();
- if (datum == -1) break;
- bout.write(datum);
+ try {
+ // image reading patch provided by Michael Krause <michakurt@web.de>
+ final BufferedInputStream bin = new BufferedInputStream(url.openStream());
+ final ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ while (true) {
+ final int datum = bin.read();
+ if (datum == -1) {
+ break;
+ }
+ bout.write(datum);
}
bout.flush();
data = bout.toByteArray();
- }
- catch (Exception e) {
- throw new ExternalGraphicException("The attribute 'src' of <fo:external-graphic> has a invalid value: '" + url + "' (" + e + ")");
+ } catch (Exception e) {
+ throw new ExternalGraphicException("The attribute 'src' of "
+ + "<fo:external-graphic> has a invalid value: '"
+ + url + "' (" + e + ")");
}
if (data == null) {
// type = to;
// }
// catch (JPEGException e) {
-// e.setMessage("Image from tag <fo:external-graphic> could not be created (src = '" + url + "'");
+// e.setMessage("Image from tag <fo:external-graphic> could "
+// + "not be created (src = '" + url + "'");
// }
// finally {
out.close();
// }
- }
- else {
+ } else {
type = ImageConstants.I_NOT_SUPPORTED;
}
}
if (type == ImageConstants.I_NOT_SUPPORTED) {
- throw new ExternalGraphicException("The tag <fo:external-graphic> does not support " + file.substring(file.lastIndexOf(".") + 1) + " - image type.");
+ throw new ExternalGraphicException("The tag <fo:external-graphic> "
+ + "does not support "
+ + file.substring(file.lastIndexOf(".") + 1)
+ + " - image type.");
}
String rtfImageCode = ImageConstants.RTF_TAGS [type];
if (type == ImageConstants.I_PNG) {
width = ImageUtil.getIntFromByteArray(data, 16, 4, true);
height = ImageUtil.getIntFromByteArray(data, 20, 4, true);
- }
- else if (type == ImageConstants.I_JPG) {
+ } else if (type == ImageConstants.I_JPG) {
int basis = -1;
byte ff = (byte) 0xff;
byte c0 = (byte) 0xc0;
for (int i = 0; i < data.length; i++) {
byte b = data[i];
- if (b != ff)
+ if (b != ff) {
continue;
- if (i == data.length - 1)
+ }
+ if (i == data.length - 1) {
continue;
+ }
b = data[i + 1];
- if (b != c0)
+ if (b != c0) {
continue;
+ }
basis = i + 5;
break;
}
width = ImageUtil.getIntFromByteArray(data, basis + 2, 2, true);
height = ImageUtil.getIntFromByteArray(data, basis, 2, true);
}
- }
- else if (type == ImageConstants.I_EMF) {
+ } else if (type == ImageConstants.I_EMF) {
width = ImageUtil.getIntFromByteArray(data, 151, 4, false);
height = ImageUtil.getIntFromByteArray(data, 155, 4, false);
}
if (widthDesired != -1) {
if (perCentW) {
writeControlWord("picscalex" + widthDesired);
- }
- else {
+ } else {
writeControlWord("picscalex" + widthDesired * 100 / width);
}
writeControlWord("picwgoal" + widthDesired);
- }
- else if (scaleUniform && heightDesired != -1) {
+ } else if (scaleUniform && heightDesired != -1) {
if (perCentH) {
writeControlWord("picscalex" + heightDesired);
- }
- else {
+ } else {
writeControlWord("picscalex" + heightDesired * 100 / height);
}
}
if (heightDesired != -1) {
if (perCentH) {
writeControlWord("picscaley" + heightDesired);
- }
- else {
+ } else {
writeControlWord("picscaley" + heightDesired * 100 / height);
}
writeControlWord("pichgoal" + heightDesired);
- }
- else if (scaleUniform && widthDesired != -1) {
+ } else if (scaleUniform && widthDesired != -1) {
if (perCentW) {
writeControlWord("picscaley" + widthDesired);
- }
- else {
+ } else {
writeControlWord("picscaley" + widthDesired * 100 / width);
}
}
int iData = data [i];
// Make positive byte
- if (iData < 0)
+ if (iData < 0) {
iData += 256;
+ }
if (iData < 16) {
// Set leading zero and append
* @param urlString Image url like "file://..."
* @throws IOException On error
*/
- public void setURL(String urlString) throws IOException
- {
+ public void setURL(String urlString) throws IOException {
URL tmpUrl = null;
- try
- {
+ try {
tmpUrl = new URL (urlString);
- }
- catch (MalformedURLException e)
- {
- try
- {
+ } catch (MalformedURLException e) {
+ try {
tmpUrl = new File (urlString).toURL ();
- }
- catch (MalformedURLException ee)
- {
- throw new ExternalGraphicException("The attribute 'src' of <fo:external-graphic> has a invalid value: '" + urlString + "' (" + ee + ")");
+ } catch (MalformedURLException ee) {
+ throw new ExternalGraphicException("The attribute 'src' of "
+ + "<fo:external-graphic> has a invalid value: '"
+ + urlString + "' (" + ee + ")");
}
}
this.url = tmpUrl;
* Gets the compression rate for the image in percent.
* @return Compression rate
*/
- public int getCompressionRate ()
- {
+ public int getCompressionRate () {
return graphicCompressionRate;
}
* true: The compression rate is valid (0..100)\n
* false: The compression rate is invalid
*/
- public boolean setCompressionRate (int percent)
- {
- if (percent < 1 || percent > 100)
+ public boolean setCompressionRate (int percent) {
+ if (percent < 1 || percent > 100) {
return false;
+ }
graphicCompressionRate = percent;
return true;
if (isPNG(data)) {
type = ImageConstants.I_PNG;
- }
- else if (isJPEG(data)) {
+ } else if (isJPEG(data)) {
type = ImageConstants.I_JPG_C;
- }
- else if (isEMF(data)) {
+ } else if (isEMF(data)) {
type = ImageConstants.I_EMF;
- }
- else if (isGIF(data)) {
+ } else if (isGIF(data)) {
type = ImageConstants.I_GIF;
- }
- else {
+ } else {
Object tmp = ImageConstants.SUPPORTED_IMAGE_TYPES.get(ext.toLowerCase());
if (tmp != null) {
type = ((Integer) tmp).intValue();
}
/** true if this element would generate no "useful" RTF content */
- public boolean isEmpty()
- {
- return url==null;
+ public boolean isEmpty() {
+ return url == null;
}
}
package org.apache.fop.rtf.rtflib.rtfdoc;
-import java.io.*;
-import java.util.*;
+//import java.io.*;
+import java.io.Writer;
+import java.io.IOException;
+import java.util.List;
+import java.util.LinkedList;
+import java.util.Iterator;
+import java.util.Collections;
import org.apache.fop.rtf.rtflib.interfaces.ITableColumnsInfo;
final int xOffset;
final int rowIndex;
- PositionedCell(RtfTableCell c,int index,int offset) {
+ PositionedCell(RtfTableCell c, int index, int offset) {
cell = c;
xOffset = offset;
rowIndex = index;
/** cells need to be sorted by row index and then by x offset */
public int compareTo(Object o) {
int result = 0;
- if(o==null) {
+ if (o == null) {
result = 1;
- } else if( !(o instanceof PositionedCell)) {
+ } else if (!(o instanceof PositionedCell)) {
result = 1;
} else {
final PositionedCell pc = (PositionedCell)o;
- if(this.rowIndex < pc.rowIndex) {
+ if (this.rowIndex < pc.rowIndex) {
result = -1;
- } else if(this.rowIndex > pc.rowIndex) {
+ } else if (this.rowIndex > pc.rowIndex) {
result = 1;
- } else if(this.xOffset < pc.xOffset) {
+ } else if (this.xOffset < pc.xOffset) {
result = -1;
- } else if(this.xOffset > pc.xOffset) {
+ } else if (this.xOffset > pc.xOffset) {
result = 1;
}
}
}
public boolean equals(Object o) {
- return o!=null && this.compareTo(o) == 0;
+ return o != null && this.compareTo(o) == 0;
}
}
*/
RtfExtraRowSet(Writer w)
throws IOException {
- super(null,w);
+ super(null, w);
}
/** Add all cells of given Table to this set for later rendering in extra rows
* @param rowIndex index of first extra row to create to hold cells of tbl
* @param xOffset horizontal position of left edge of first column of tbl
*/
- int addTable(RtfTable tbl,int rowIndex,int xOffset) {
+ int addTable(RtfTable tbl, int rowIndex, int xOffset) {
// process all rows of the table
- for(Iterator it = tbl.getChildren().iterator(); it.hasNext(); ) {
+ for (Iterator it = tbl.getChildren().iterator(); it.hasNext();) {
final RtfElement e = (RtfElement)it.next();
- if(e instanceof RtfTableRow) {
- addRow((RtfTableRow)e,rowIndex,xOffset);
+ if (e instanceof RtfTableRow) {
+ addRow((RtfTableRow)e, rowIndex, xOffset);
rowIndex++;
- m_maxRowIndex = Math.max(rowIndex,m_maxRowIndex);
+ m_maxRowIndex = Math.max(rowIndex, m_maxRowIndex);
}
}
return rowIndex;
}
/** add all cells of given row to this set */
- private void addRow(RtfTableRow row,int rowIndex,int xOffset) {
- for(Iterator it = row.getChildren().iterator(); it.hasNext(); ) {
+ private void addRow(RtfTableRow row, int rowIndex, int xOffset) {
+ for (Iterator it = row.getChildren().iterator(); it.hasNext();) {
final RtfElement e = (RtfElement)it.next();
- if(e instanceof RtfTableCell) {
+ if (e instanceof RtfTableCell) {
final RtfTableCell c = (RtfTableCell)e;
- m_cells.add(new PositionedCell(c,rowIndex,xOffset));
+ m_cells.add(new PositionedCell(c, rowIndex, xOffset));
xOffset += c.getCellWidth();
}
}
}
/** create an extra cell to hold content that comes after a nested table in a cell
- * Modified by Boris Poudérous in order to permit the extra cell to have the attributes of its parent cell
+ * Modified by Boris Poudérous in order to permit the extra cell to have
+ * the attributes of its parent cell
*/
- RtfTableCell createExtraCell(int rowIndex,int xOffset,int cellWidth,RtfAttributes parentCellAttributes)
+ RtfTableCell createExtraCell(int rowIndex, int xOffset, int cellWidth,
+ RtfAttributes parentCellAttributes)
throws IOException {
- final RtfTableCell c = new RtfTableCell(null,m_writer,cellWidth,parentCellAttributes,DEFAULT_IDNUM);
- m_cells.add(new PositionedCell(c,rowIndex,xOffset));
+ final RtfTableCell c = new RtfTableCell(null, m_writer, cellWidth,
+ parentCellAttributes, DEFAULT_IDNUM);
+ m_cells.add(new PositionedCell(c, rowIndex, xOffset));
return c;
}
// process all extra cells by rendering them into extra rows
List rowCells = null;
int rowIndex = -1;
- for(Iterator it = m_cells.iterator(); it.hasNext(); ) {
+ for (Iterator it = m_cells.iterator(); it.hasNext();) {
final PositionedCell pc = (PositionedCell)it.next();
- if(pc.rowIndex != rowIndex) {
+ if (pc.rowIndex != rowIndex) {
// starting a new row, render previous one
- if(rowCells!=null) writeRow(rowCells);
+ if (rowCells != null) {
+ writeRow(rowCells);
+ }
rowIndex = pc.rowIndex;
rowCells = new LinkedList();
}
}
// render last row
- if(rowCells!=null) writeRow(rowCells);
+ if (rowCells != null) {
+ writeRow(rowCells);
+ }
}
/** write one RtfTableRow containing given PositionedCells */
private void writeRow(List cells)
throws IOException {
- if(allCellsEmpty(cells)) return;
+ if (allCellsEmpty(cells)) {
+ return;
+ }
- final RtfTableRow row = new RtfTableRow(null,m_writer,DEFAULT_IDNUM);
+ final RtfTableRow row = new RtfTableRow(null, m_writer, DEFAULT_IDNUM);
int cellIndex = 0;
// Get the context of the table that holds the nested table
float xOffset = 0;
float xOffsetOfLastPositionedCell = 0;
- for(Iterator it = cells.iterator(); it.hasNext(); ) {
+ for (Iterator it = cells.iterator(); it.hasNext();) {
final PositionedCell pc = (PositionedCell)it.next();
// if first cell is not at offset 0, add placeholder cell
// TODO should be merged with the cell that is above it
- if(cellIndex==0 && pc.xOffset > 0) {
+ if (cellIndex == 0 && pc.xOffset > 0) {
/**
* Added by Boris Poudérous
*/
// Add empty cells merged vertically with the cells above and with the same widths
// (BEFORE the cell that contains the nested table)
- for (int i = 0; (xOffset < pc.xOffset) && (i < parentITableColumnsInfo.getNumberOfColumns()); i++) {
- // Get the width of the cell above
- xOffset += parentITableColumnsInfo.getColumnWidth();
- // Create the empty cell merged vertically
- row.newTableCellMergedVertically((int)parentITableColumnsInfo.getColumnWidth(), pc.cell.m_attrib);
- // Select next column in order to have its width
- parentITableColumnsInfo.selectNextColumn();
- }
+ for (int i = 0; (xOffset < pc.xOffset)
+ && (i < parentITableColumnsInfo.getNumberOfColumns()); i++) {
+ // Get the width of the cell above
+ xOffset += parentITableColumnsInfo.getColumnWidth();
+ // Create the empty cell merged vertically
+ row.newTableCellMergedVertically((int)parentITableColumnsInfo.getColumnWidth(),
+ pc.cell.m_attrib);
+ // Select next column in order to have its width
+ parentITableColumnsInfo.selectNextColumn();
+ }
}
row.addChild(pc.cell);
/**
* Added by Boris Poudérous
*/
- // Add empty cells merged vertically with the cells above AFTER the cell that contains the nested table
+ // Add empty cells merged vertically with the cells above AFTER the cell
+ // that contains the nested table
// The cells added have the same widths than the cells above.
- if (parentITableColumnsInfo.getColumnIndex() < (parentITableColumnsInfo.getNumberOfColumns() - 1))
- {
+ if (parentITableColumnsInfo.getColumnIndex()
+ < (parentITableColumnsInfo.getNumberOfColumns() - 1)) {
parentITableColumnsInfo.selectNextColumn();
- while (parentITableColumnsInfo.getColumnIndex() < parentITableColumnsInfo.getNumberOfColumns())
- {
+ while (parentITableColumnsInfo.getColumnIndex()
+ < parentITableColumnsInfo.getNumberOfColumns()) {
// Create the empty cell merged vertically
- // TODO : the new cells after the extra cell don't have its attributes as we did for the previous cells.
- // => in fact the m_attrib below (last argument) is empty => should be the attributes of the above cells.
- row.newTableCellMergedVertically((int)parentITableColumnsInfo.getColumnWidth(), m_attrib);
+ // TODO : the new cells after the extra cell don't have its
+ // attributes as we did for the previous cells.
+ // => in fact the m_attrib below (last argument) is
+ // empty => should be the attributes of the above cells.
+ row.newTableCellMergedVertically((int)parentITableColumnsInfo.getColumnWidth(),
+ m_attrib);
// Select next column in order to have its width
parentITableColumnsInfo.selectNextColumn();
}
*/
private static boolean allCellsEmpty(List cells) {
boolean empty = true;
- for(Iterator it = cells.iterator(); it.hasNext(); ) {
+ for (Iterator it = cells.iterator(); it.hasNext();) {
final PositionedCell pc = (PositionedCell)it.next();
- if(pc.cell.containsText()) {
+ if (pc.cell.containsText()) {
empty = false;
break;
}
* @return The table context of the parent table
* Added by Boris Poudérous on july 2002 in order to process nested tables
*/
- public ITableColumnsInfo getParentITableColumnsInfo()
- {
+ public ITableColumnsInfo getParentITableColumnsInfo() {
return this.parentITableColumnsInfo;
}
- public void setParentITableColumnsInfo (ITableColumnsInfo parentITableColumnsInfo)
- {
+ public void setParentITableColumnsInfo (ITableColumnsInfo parentITableColumnsInfo) {
this.parentITableColumnsInfo = parentITableColumnsInfo;
}
/** - end - */
import org.apache.fop.rtf.rtflib.exceptions.RtfStructureException;
//import org.apache.fop.rtf.rtflib.jfor.converter.ConverterLogChannel;
-import java.io.*;
+//import java.io.*;
+import java.io.Writer;
+import java.io.IOException;
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.OutputStreamWriter;
/** Models the top-level structure of an RTF file.
* @see RtfFileExample
private RtfDocumentArea m_docArea;
// private ConverterLogChannel m_log;
private RtfContainer m_listTableContainer;
- private int listNum=0;
+ private int listNum = 0;
/** Create an RTF file that outputs to the given Writer */
public RtfFile(Writer w) throws IOException {
- super(null,w);
+ super(null, w);
}
/** optional log channel */
/** If called, must be called before startDocumentArea */
public RtfHeader startHeader()
throws IOException {
- if(m_header!=null) throw new RtfStructureException("startHeader called more than once");
- m_header = new RtfHeader(this,m_writer);
- m_listTableContainer = new RtfContainer(this,m_writer);
+ if (m_header != null) {
+ throw new RtfStructureException("startHeader called more than once");
+ }
+ m_header = new RtfHeader(this, m_writer);
+ m_listTableContainer = new RtfContainer(this, m_writer);
return m_header;
}
/** Creates the list table.*/
public RtfListTable startListTable(RtfAttributes attr)
- throws IOException{
+ throws IOException {
listNum++;
- m_listTable = new RtfListTable(this,m_writer,new Integer(listNum),attr);
+ m_listTable = new RtfListTable(this, m_writer, new Integer(listNum), attr);
m_listTableContainer.addChild(m_listTable);
return m_listTable;
}
must be able to have multiple page definition, and corresponding
Document areas */
public RtfPageArea startPageArea()
- throws IOException,RtfStructureException {
- if(m_pageArea!=null) throw new RtfStructureException("startPageArea called more than once");
+ throws IOException, RtfStructureException {
+ if (m_pageArea != null) {
+ throw new RtfStructureException("startPageArea called more than once");
+ }
// create an empty header if there was none
- if(m_header==null) startHeader();
+ if (m_header == null) {
+ startHeader();
+ }
m_header.close();
- m_pageArea = new RtfPageArea(this,m_writer);
+ m_pageArea = new RtfPageArea(this, m_writer);
addChild(m_pageArea);
return m_pageArea;
}
/** Call startPageArea if needed and return the page area object. */
public RtfPageArea getPageArea()
- throws IOException,RtfStructureException {
- if(m_pageArea== null) return startPageArea();
+ throws IOException, RtfStructureException {
+ if (m_pageArea == null) {
+ return startPageArea();
+ }
return m_pageArea;
}
* Must be called once only.
*/
public RtfDocumentArea startDocumentArea()
- throws IOException,RtfStructureException {
- if(m_docArea!=null) throw new RtfStructureException("startDocumentArea called more than once");
+ throws IOException, RtfStructureException {
+ if (m_docArea != null) {
+ throw new RtfStructureException("startDocumentArea called more than once");
+ }
// create an empty header if there was none
- if(m_header==null) startHeader();
+ if (m_header == null) {
+ startHeader();
+ }
m_header.close();
- m_docArea = new RtfDocumentArea(this,m_writer);
+ m_docArea = new RtfDocumentArea(this, m_writer);
addChild(m_docArea);
return m_docArea;
}
/** Call startDocumentArea if needed and return the document area object. */
public RtfDocumentArea getDocumentArea()
- throws IOException,RtfStructureException {
- if(m_docArea == null) return startDocumentArea();
+ throws IOException, RtfStructureException {
+ if (m_docArea == null) {
+ return startDocumentArea();
+ }
return m_docArea;
}
/** overridden to write RTF prefix code, what comes before our children */
- protected void writeRtfPrefix() throws IOException
- {
+ protected void writeRtfPrefix() throws IOException {
writeGroupMark(true);
writeControlWord("rtf1");
}
/** overridden to write RTF suffix code, what comes after our children */
- protected void writeRtfSuffix() throws IOException
- {
+ protected void writeRtfSuffix() throws IOException {
writeGroupMark(false);
}
public static void main(String args[])
throws Exception {
Writer w = null;
- if(args.length != 0) {
+ if (args.length != 0) {
final String outFile = args[0];
System.err.println("Outputting RTF to file '" + outFile + "'");
w = new BufferedWriter(new FileWriter(outFile));
final RtfSection sect = f.startDocumentArea().newSection();
final RtfParagraph p = sect.newParagraph();
- p.newText("Hello, RTF world.\n",null);
+ p.newText("Hello, RTF world.\n", null);
final RtfAttributes attr = new RtfAttributes();
attr.set(RtfText.ATTR_BOLD);
attr.set(RtfText.ATTR_ITALIC);
- attr.set(RtfText.ATTR_FONT_SIZE,36);
- p.newText("This is bold, italic, 36 points",attr);
+ attr.set(RtfText.ATTR_FONT_SIZE, 36);
+ p.newText("This is bold, italic, 36 points", attr);
f.flush();
System.err.println("RtfFile test: all done.");
* RTF font table
* @author Andreas Putz a.putz@skynamics.com
*/
-public class RtfFontManager
-{
+public class RtfFontManager {
//////////////////////////////////////////////////
// @@ Members
//////////////////////////////////////////////////
/**
* Constructor.
*/
- private RtfFontManager ()
- {
+ private RtfFontManager () {
fontTable = new Vector ();
fontIndex = new Hashtable ();
*
* @return The instance of RtfFontManager
*/
- public static RtfFontManager getInstance ()
- {
- if (instance == null)
- {
+ public static RtfFontManager getInstance () {
+ if (instance == null) {
instance = new RtfFontManager ();
}
/**
* Initialize the font table.
*/
- private void init ()
- {
+ private void init () {
// getFontNumber ("Helvetica");
//Chanded by R.Marra default font Arial
*
* @return The number of the font in the table
*/
- public int getFontNumber (String family)
- {
+ public int getFontNumber (String family) {
family = family.toLowerCase ();
Object o = fontIndex.get (family);
int retVal;
- if (o == null)
- {
+ if (o == null) {
addFont (family);
retVal = fontTable.size () - 1;
- }
- else
- {
+ } else {
retVal = ((Integer) o).intValue ();
}
*
* @throws IOException On error
*/
- public void writeFonts (RtfHeader header) throws IOException
- {
- if (fontTable == null || fontTable.size () == 0)
- {
+ public void writeFonts (RtfHeader header) throws IOException {
+ if (fontTable == null || fontTable.size () == 0) {
return;
}
int len = fontTable.size ();
- for (int i = 0; i < len; i++)
- {
+ for (int i = 0; i < len; i++) {
header.writeGroupMark (true);
header.write ("\\f" + i);
header.write (" " + (String) fontTable.elementAt (i));
*
* @param i Identifier of font
*/
- private void addFont (String family)
- {
+ private void addFont (String family) {
fontIndex.put (family, new Integer (fontTable.size ()));
fontTable.addElement (family);
}
* @author Andreas Putz a.putz@skynamics.com
*/
-class RtfFontTable extends RtfElement
-{
+class RtfFontTable extends RtfElement {
/** Create an RTF header */
- RtfFontTable(RtfHeader h, Writer w) throws IOException
- {
- super(h,w);
+ RtfFontTable(RtfHeader h, Writer w) throws IOException {
+ super(h, w);
}
/** write our contents to m_writer. */
- protected void writeRtfContent() throws IOException
- {
+ protected void writeRtfContent() throws IOException {
RtfFontManager.getInstance ().writeFonts ((RtfHeader)m_parent);
}
/** true if this element would generate no "useful" RTF content */
- public boolean isEmpty()
- {
+ public boolean isEmpty() {
return false;
}
}
package org.apache.fop.rtf.rtflib.rtfdoc;
-import java.util.*;
+//import java.util.*;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
import java.io.Writer;
import java.io.IOException;
//import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;
private final Map m_userProperties = new HashMap();
/** Create an RTF header */
- RtfHeader(RtfFile f,Writer w) throws IOException {
- super(f,w);
- new RtfFontTable(this,w);
+ RtfHeader(RtfFile f, Writer w) throws IOException {
+ super(f, w);
+ new RtfFontTable(this, w);
// m_userProperties.put("jforVersion",JForVersionInfo.getLongVersionInfo());
}
/** write user properties if any */
private void writeUserProperties() throws IOException {
- if(m_userProperties.size() > 0) {
+ if (m_userProperties.size() > 0) {
writeGroupMark(true);
writeStarControlWord("userprops");
- for(Iterator it = m_userProperties.entrySet().iterator(); it.hasNext(); ) {
+ for (Iterator it = m_userProperties.entrySet().iterator(); it.hasNext();) {
final Map.Entry entry = (Map.Entry)it.next();
writeGroupMark(true);
writeControlWord("propname");
- RtfStringConverter.getInstance().writeRtfString(m_writer,entry.getKey().toString());
+ RtfStringConverter.getInstance().writeRtfString(m_writer,
+ entry.getKey().toString());
writeGroupMark(false);
writeControlWord("proptype30");
writeGroupMark(true);
writeControlWord("staticval");
- RtfStringConverter.getInstance().writeRtfString(m_writer,entry.getValue().toString());
+ RtfStringConverter.getInstance().writeRtfString(m_writer,
+ entry.getValue().toString());
writeGroupMark(false);
}
writeGroupMark(false);
/** write to our Writer using an RtfStringConverter */
void writeRtfString(String toWrite) throws IOException {
- RtfStringConverter.getInstance().writeRtfString(m_writer,toWrite);
+ RtfStringConverter.getInstance().writeRtfString(m_writer, toWrite);
}
}
*
* {\field {\*\fldinst HYPERLINK "http://www.test.de" }{\fldrslt Joe Smith}}
*/
-public class RtfHyperLink extends RtfContainer implements IRtfTextContainer
-{
+public class RtfHyperLink extends RtfContainer implements IRtfTextContainer {
//////////////////////////////////////////////////
// @@ Members
* @param attributes a <code>RtfAttributes</code> value
*/
public RtfHyperLink (IRtfTextContainer parent, Writer writer, String str, RtfAttributes attr)
- throws IOException
- {
+ throws IOException {
super ((RtfContainer) parent, writer, attr);
new RtfText (this, writer, str, attr);
}
*
* @exception IOException On error
*/
- public void writeRtfPrefix () throws IOException
- {
+ public void writeRtfPrefix () throws IOException {
super.writeGroupMark (true);
super.writeControlWord ("field");
super.writeControlWord ("fldrslt");
// start a group for this paragraph and write our own attributes if needed
- if (m_attrib != null && m_attrib.isSet ("cs"))
- {
+ if (m_attrib != null && m_attrib.isSet ("cs")) {
writeGroupMark (true);
writeAttributes(m_attrib, new String [] {"cs"});
}
*
* @exception IOException On error
*/
- public void writeRtfSuffix () throws IOException
- {
- if (m_attrib != null && m_attrib.isSet ("cs"))
- {
+ public void writeRtfSuffix () throws IOException {
+ if (m_attrib != null && m_attrib.isSet ("cs")) {
writeGroupMark (false);
}
super.writeGroupMark (false);
* @param str if not null, added to the RtfText created
*/
public RtfText newText (String str) throws IOException {
- return newText (str,null);
+ return newText (str, null);
}
/** close current text run if any and start a new one
* @param str if not null, added to the RtfText created
*/
- public RtfText newText (String str,RtfAttributes attr) throws IOException
- {
+ public RtfText newText (String str, RtfAttributes attr) throws IOException {
closeAll ();
mText = new RtfText (this, m_writer, str, attr);
return mText;
}
/** IRtfTextContainer requirement: return a copy of our attributes */
- public RtfAttributes getTextContainerAttributes()
- {
- if (m_attrib == null) return null;
+ public RtfAttributes getTextContainerAttributes() {
+ if (m_attrib == null) {
+ return null;
+ }
return (RtfAttributes) this.m_attrib.clone ();
}
/** add a line break */
- public void newLineBreak () throws IOException
- {
+ public void newLineBreak () throws IOException {
new RtfLineBreak (this, m_writer);
}
// @@ Common container methods
//////////////////////////////////////////////////
- private void closeCurrentText () throws IOException
- {
- if (mText != null) mText.close ();
+ private void closeCurrentText () throws IOException {
+ if (mText != null) {
+ mText.close ();
+ }
}
- private void closeAll () throws IOException
- {
+ private void closeAll () throws IOException {
closeCurrentText();
}
*
* @param url Link url like "http://..."
*/
- public void setExternalURL (String url)
- {
+ public void setExternalURL (String url) {
this.url = url;
}
*
* @param jumpTo Name of the text mark
*/
- public void setInternalURL (String jumpTo)
- {
+ public void setInternalURL (String jumpTo) {
int now = jumpTo.length ();
int max = RtfBookmark.maxBookmarkLength;
this.url = "#" + jumpTo.substring (0, now > max ? max : now);
this.url = this.url.replace (' ', RtfBookmark.replaceCharacter);
}
- public boolean isEmpty ()
- {
+ public boolean isEmpty () {
return false;
}
}
import java.io.Writer;
-import java.io.*;
-import java.util.*;
+import java.util.Iterator;
import java.io.IOException;
/*
*/
public class RtfJforCmd extends RtfContainer {
- private final String PARA_KEEP_ON ="para-keep:on";
- private final String PARA_KEEP_OFF ="para-keep:off";
+ private final String PARA_KEEP_ON = "para-keep:on";
+ private final String PARA_KEEP_OFF = "para-keep:off";
private final RtfAttributes m_attrib;
private ParagraphKeeptogetherContext m_paragraphKeeptogetherContext;
RtfJforCmd(RtfContainer parent, Writer w, RtfAttributes attrs) throws IOException {
- super((RtfContainer)parent,w);
+ super((RtfContainer)parent, w);
m_attrib = attrs;
- m_paragraphKeeptogetherContext=ParagraphKeeptogetherContext.getInstance();
+ m_paragraphKeeptogetherContext = ParagraphKeeptogetherContext.getInstance();
}
//Execute all jfor-cmd commands
//TODO create one class for each jfor command ?
- for(Iterator it = m_attrib.nameIterator(); it.hasNext(); ) {
+ for (Iterator it = m_attrib.nameIterator(); it.hasNext();) {
final String cmd = (String)it.next();
if (cmd.equals(PARA_KEEP_ON)) {
m_paragraphKeeptogetherContext.KeepTogetherOpen();
- }else if (cmd.equals(PARA_KEEP_OFF)) {
+ } else if (cmd.equals(PARA_KEEP_OFF)) {
m_paragraphKeeptogetherContext.KeepTogetherClose();
- }else {
-// this.getRtfFile ().getLog ().logInfo ("JFOR-CMD ignored, command not recognised:"+cmd);
+ } else {
+// this.getRtfFile ().getLog ().logInfo
+// ("JFOR-CMD ignored, command not recognised:"+cmd);
}
}
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
-public class RtfLineBreak extends RtfElement
-{
+public class RtfLineBreak extends RtfElement {
/** Create an RTF paragraph as a child of given container with default attributes */
- RtfLineBreak(IRtfTextContainer parent, Writer w) throws IOException
- {
- super((RtfContainer)parent,w);
+ RtfLineBreak(IRtfTextContainer parent, Writer w) throws IOException {
+ super((RtfContainer)parent, w);
}
/** overridden to write our attributes before our content */
- protected void writeRtfContent() throws IOException
- {
+ protected void writeRtfContent() throws IOException {
writeControlWord("line");
}
/** true if this element would generate no "useful" RTF content */
- public boolean isEmpty()
- {
+ public boolean isEmpty() {
return false;
}
}
\ No newline at end of file
/** Create an RTF list as a child of given container with given attributes */
RtfList(RtfContainer parent, Writer w, RtfAttributes attr) throws IOException {
- super((RtfContainer)parent,w,attr);
+ super((RtfContainer)parent, w, attr);
m_numberingStyle = new NumberingStyle();
//create a new list table entry for the list
m_listTable = (getRtfFile()).startListTable(attr);
/** overridden to setup the list: start a group with appropriate attributes */
protected void writeRtfPrefix() throws IOException {
// pard causes word97 (and sometimes 2000 too) to crash if the list is nested in a table
- if(!m_hasTableParent) writeControlWord("pard");
+ if (!m_hasTableParent) {
+ writeControlWord("pard");
+ }
- writeOneAttribute(RtfText.LEFT_INDENT_FIRST,m_attrib.getValue(RtfListTable.LIST_INDENT));
- writeOneAttribute(RtfText.LEFT_INDENT_BODY,m_attrib.getValue(RtfText.LEFT_INDENT_BODY));
+ writeOneAttribute(RtfText.LEFT_INDENT_FIRST, m_attrib.getValue(RtfListTable.LIST_INDENT));
+ writeOneAttribute(RtfText.LEFT_INDENT_BODY, m_attrib.getValue(RtfText.LEFT_INDENT_BODY));
// put the whole list in a group
writeGroupMark(true);
//Modified by Chris Scott
//fixes second line indentation
- if(m_numberingStyle.isBulletedList) {
+ if (m_numberingStyle.isBulletedList) {
// bulleted list
writeControlWord("pnlvlblt");
writeControlWord("ilvl0");
writeControlWord("pnf1");
writeGroupMark(true);
writeControlWord("pndec");
- writeOneAttribute(RtfListTable.LIST_FONT_TYPE,"2");
+ writeOneAttribute(RtfListTable.LIST_FONT_TYPE, "2");
writeControlWord("pntxtb");
writeControlWord("'b7");
writeGroupMark(false);
// close group that encloses the whole list
writeGroupMark(false);
- // reset paragraph defaults to make sure list ends
- // but pard causes word97 (and sometimes 2000 too) to crash if the list is nested in a table
- if(!m_hasTableParent) writeControlWord("pard");
+ /* reset paragraph defaults to make sure list ends
+ * but pard causes word97 (and sometimes 2000 too) to crash if the list
+ * is nested in a table
+ */
+ if (!m_hasTableParent) {
+ writeControlWord("pard");
+ }
}
/** close current list item and start a new one */
public RtfListItem newListItem() throws IOException {
- if(m_item != null) m_item.close();
- m_item = new RtfListItem(this,m_writer);
+ if (m_item != null) {
+ m_item.close();
+ }
+ m_item = new RtfListItem(this, m_writer);
return m_item;
}
import java.io.Writer;
import java.io.IOException;
-import java.io.*;
/** Model of an RTF list item, which can contain RTF paragraphs
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
/** special RtfParagraph that writes list item setup code before its content */
private class RtfListItemParagraph extends RtfParagraph {
- RtfListItemParagraph(RtfListItem rli,RtfAttributes attrs)
+ RtfListItemParagraph(RtfListItem rli, RtfAttributes attrs)
throws IOException {
- super(rli,rli.m_writer,attrs);
+ super(rli, rli.m_writer, attrs);
}
protected void writeRtfPrefix() throws IOException {
super.writeRtfPrefix();
// for bulleted list, add list item setup group before paragraph contents
- if(m_parentList.isBulletedList()) {
+ if (m_parentList.isBulletedList()) {
writeGroupMark(true);
writeControlWord("pntext");
writeControlWord("f" + RtfFontManager.getInstance().getFontNumber("Symbol"));
writeControlWord("'b7");
writeControlWord("tab");
writeGroupMark(false);
- }else{
+ } else {
writeGroupMark(true);
writeControlWord("pntext");
writeGroupMark(false);
/** Create an RTF list item as a child of given container with default attributes */
RtfListItem(RtfList parent, Writer w) throws IOException {
- super((RtfContainer)parent,w);
+ super((RtfContainer)parent, w);
m_parentList = parent;
}
/** Create an RTF list item as a child of given container with given attributes */
RtfListItem(RtfList parent, Writer w, RtfAttributes attr) throws IOException {
- super((RtfContainer)parent,w,attr);
+ super((RtfContainer)parent, w, attr);
m_parentList = parent;
}
/** close current paragraph and start a new one */
/** close current paragraph if any and start a new one */
public RtfParagraph newParagraph(RtfAttributes attrs) throws IOException {
- if(m_paragraph != null) m_paragraph.close();
- m_paragraph = new RtfListItemParagraph(this,attrs);
+ if (m_paragraph != null) {
+ m_paragraph.close();
+ }
+ m_paragraph = new RtfListItemParagraph(this, attrs);
return m_paragraph;
}
package org.apache.fop.rtf.rtflib.rtfdoc;
-import java.util.*;
+import java.util.Date;
+import java.util.Random;
import java.io.Writer;
import java.io.IOException;
//import org.apache.fop.rtf.rtflib.jfor.main.JForVersionInfo;
* esp. Adobe FrameMaker read lists from RTF.
* @author Christopher Scott, scottc@westinghouse.com
*/
-public class RtfListTable extends RtfContainer{
+public class RtfListTable extends RtfContainer {
//number of list in document
private Integer listNum;
public static final String LIST_NUM_POSITION = "levelnumbers";
public static final String LIST_NAME = "listname ;";
public static final String LIST_ID = "listid";
- public static final String LIST_FONT_TYPE ="f";
+ public static final String LIST_FONT_TYPE = "f";
public static final String LIST_OVR_TABLE = "listoverridetable";
public static final String LIST_OVR = "listoverride";
/**RtfListTable Constructor: sets the number of the list, and allocates
* for the RtfAttributes */
public RtfListTable(RtfContainer parent, Writer w, Integer num, RtfAttributes attrs)
- throws IOException{
+ throws IOException {
super(parent, w, attrs);
listNum = new Integer(num.intValue());
//random number generator for ids
Date runTime = new Date();
Random listIdGenerator = new Random(runTime.getTime());
listId = new Integer(listIdGenerator.nextInt());
- m_attrib.set(LIST_ID,listId.toString());
+ m_attrib.set(LIST_ID, listId.toString());
listTemplateId = new Integer(listIdGenerator.nextInt());
- m_attrib.set(LIST_NUMBER_TYPE,0);
+ m_attrib.set(LIST_NUMBER_TYPE, 0);
}
public void setParentList(RtfList parent) {
/** Set whether the list is a bulleted list not, and set attributes
* accordingly */
private void setListType() {
- if(parentList.isBulletedList()){
+ if (parentList.isBulletedList()) {
// bullet definition for bulleted lists
// Chris Scott's version was "\\\'01\\u-3913 ?;"
// 'b7 is what was used in jfor V0.5.2
- m_attrib.set(LIST_TEXT_FORM,"\\\'01\\'b7 ?;");
+ m_attrib.set(LIST_TEXT_FORM, "\\\'01\\'b7 ?;");
m_attrib.set(LIST_NUM_POSITION);
- m_attrib.set(LIST_NUMBER_TYPE,23);
- m_attrib.set(LIST_FONT_TYPE,2);
- }else{
+ m_attrib.set(LIST_NUMBER_TYPE, 23);
+ m_attrib.set(LIST_FONT_TYPE, 2);
+ } else {
m_attrib.set(LIST_TEXT_FORM, "\\\'03\\\'00. ;");
m_attrib.set(LIST_NUM_POSITION, "\\\'01;");
- m_attrib.set(LIST_NUMBER_TYPE,0);
- m_attrib.set(LIST_FONT_TYPE,0);
+ m_attrib.set(LIST_NUMBER_TYPE, 0);
+ m_attrib.set(LIST_FONT_TYPE, 0);
}
}
writeGroupMark(true);
writeControlWordNS(LIST);
- writeOneAttributeNS(LIST_TEMPLATE_ID,listTemplateId.toString());
- writeOneAttributeNS(LIST,m_attrib.getValue(LIST));
+ writeOneAttributeNS(LIST_TEMPLATE_ID, listTemplateId.toString());
+ writeOneAttributeNS(LIST, m_attrib.getValue(LIST));
writeGroupMark(true);
writeControlWordNS(LIST_LEVEL);
- writeOneAttributeNS(LIST_NUMBER_TYPE,m_attrib.getValue(LIST_NUMBER_TYPE));
- writeOneAttributeNS(LIST_JUSTIFICATION,m_attrib.getValue(LIST_JUSTIFICATION));
- writeOneAttributeNS(LIST_FOLLOWING_CHAR,m_attrib.getValue(LIST_FOLLOWING_CHAR));
- writeOneAttributeNS(LIST_START_AT,m_attrib.getValue(LIST_START_AT));
- writeOneAttributeNS(LIST_SPACE,new Integer(0));
- writeOneAttributeNS(LIST_INDENT,m_attrib.getValue(LIST_INDENT));
+ writeOneAttributeNS(LIST_NUMBER_TYPE, m_attrib.getValue(LIST_NUMBER_TYPE));
+ writeOneAttributeNS(LIST_JUSTIFICATION, m_attrib.getValue(LIST_JUSTIFICATION));
+ writeOneAttributeNS(LIST_FOLLOWING_CHAR, m_attrib.getValue(LIST_FOLLOWING_CHAR));
+ writeOneAttributeNS(LIST_START_AT, m_attrib.getValue(LIST_START_AT));
+ writeOneAttributeNS(LIST_SPACE, new Integer(0));
+ writeOneAttributeNS(LIST_INDENT, m_attrib.getValue(LIST_INDENT));
writeGroupMark(true);
- writeOneAttributeNS(LIST_TEXT_FORM,m_attrib.getValue(LIST_TEXT_FORM));
+ writeOneAttributeNS(LIST_TEXT_FORM, m_attrib.getValue(LIST_TEXT_FORM));
writeGroupMark(false);
writeGroupMark(true);
- writeOneAttributeNS(LIST_NUM_POSITION,m_attrib.getValue(LIST_NUM_POSITION));
+ writeOneAttributeNS(LIST_NUM_POSITION, m_attrib.getValue(LIST_NUM_POSITION));
writeGroupMark(false);
- writeOneAttributeNS(LIST_FONT_TYPE,m_attrib.getValue(LIST_FONT_TYPE));
+ writeOneAttributeNS(LIST_FONT_TYPE, m_attrib.getValue(LIST_FONT_TYPE));
writeGroupMark(false);
writeGroupMark(true);
writeControlWordNS(LIST_NAME);
writeGroupMark(false);
- writeOneAttributeNS(LIST_ID,listId.toString());
+ writeOneAttributeNS(LIST_ID, listId.toString());
writeGroupMark(false);
writeGroupMark(false);
writeGroupMark(true);
writeStarControlWordNS(LIST_OVR_TABLE);
writeGroupMark(true);
writeControlWordNS(LIST_OVR);
- writeOneAttributeNS(LIST_ID,listId.toString());
- writeOneAttributeNS(LIST_OVR_COUNT,new Integer(0));
- writeOneAttributeNS(LIST_NUMBER,listNum.toString());
+ writeOneAttributeNS(LIST_ID, listId.toString());
+ writeOneAttributeNS(LIST_OVR_COUNT, new Integer(0));
+ writeOneAttributeNS(LIST_NUMBER, listNum.toString());
writeGroupMark(false);
writeGroupMark(false);
}
package org.apache.fop.rtf.rtflib.rtfdoc;
import java.io.Writer;
-import java.io.*;
-import java.util.*;
import java.io.IOException;
/* @author Christopher Scott, scottc@westinghouse.com */
public class RtfNull
-extends RtfContainer{
+extends RtfContainer {
RtfNull(RtfPage parent, Writer w) throws IOException {
- super((RtfContainer)parent,w);
+ super((RtfContainer)parent, w);
}
}
\ No newline at end of file
package org.apache.fop.rtf.rtflib.rtfdoc;
-import java.io.Writer;
-import java.util.*;
-import java.io.IOException;
-
/** Simplistic options definitions for RTF generation
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
-public class RtfOptions
-{
+public class RtfOptions {
/** if true, RtfParagraphs that have no children do not generate any RTF code */
public boolean ignoreEmptyParagraphs() { return true; }
import java.io.Writer;
import java.io.IOException;
-import java.io.*;
/* @author Christopher Scott, scottc@westinghouse.com */
public class RtfPageArea
-extends RtfContainer
-{
+extends RtfContainer {
private RtfPage m_currentPage;
private RtfNull nullChild;
private RtfAttributes childAttributes;
/** Create an RTF element as a child of given container */
- RtfPageArea(RtfFile f,Writer w) throws IOException
- {
- super(f,w);
+ RtfPageArea(RtfFile f, Writer w) throws IOException {
+ super(f, w);
}
/** close current Rtfpage if any and create a new one */
- public RtfPage newPage(RtfAttributes attr) throws IOException
- {
- if(m_currentPage != null){
+ public RtfPage newPage(RtfAttributes attr) throws IOException {
+ if (m_currentPage != null) {
m_currentPage.close();
}
- m_currentPage = new RtfPage(this,m_writer,attr);
+ m_currentPage = new RtfPage(this, m_writer, attr);
return m_currentPage;
}
- protected boolean okToWriteRtf()
- {
+ protected boolean okToWriteRtf() {
return true;
}
}
\ No newline at end of file
* @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
*/
-public class RtfPageBreak extends RtfElement
-{
+public class RtfPageBreak extends RtfElement {
/** Create an RTF paragraph as a child of given container with default attributes */
- RtfPageBreak(IRtfPageBreakContainer parent, Writer w) throws IOException
- {
- super((RtfContainer)parent,w);
+ RtfPageBreak(IRtfPageBreakContainer parent, Writer w) throws IOException {
+ super((RtfContainer)parent, w);
}
/** overridden to write our attributes before our content */
- protected void writeRtfContent() throws IOException
- {
+ protected void writeRtfContent() throws IOException {
writeControlWord("page");
}
/** true if this element would generate no "useful" RTF content */
- public boolean isEmpty()
- {
+ public boolean isEmpty() {
return false;
}
}
\ No newline at end of file
import java.io.IOException;
/* @author Christopher Scott, scottc@westinghouse.com */
-public class RtfPageNumber extends RtfContainer
-{
+public class RtfPageNumber extends RtfContainer {
/** RtfText attributes: fields */
//must be carefull of group markings and star control
//ie page field:
public static String RTF_FIELD_RESULT = "fldrslt";
/** Create an RTF paragraph as a child of given container with default attributes */
- RtfPageNumber(IRtfPageNumberContainer parent, Writer w) throws IOException
- {
- super((RtfContainer)parent,w);
+ RtfPageNumber(IRtfPageNumberContainer parent, Writer w) throws IOException {
+ super((RtfContainer)parent, w);
}
/** Create an RTF page number as a child of given paragraph,
* copying the paragraph attributes
*/
- RtfPageNumber(RtfParagraph parent, Writer w) throws IOException
- {
+ RtfPageNumber(RtfParagraph parent, Writer w) throws IOException {
// Adds the attributes of the parent paragraph
- super((RtfContainer)parent,w, parent.m_attrib);
+ super((RtfContainer)parent, w, parent.m_attrib);
// copy parent's text attributes
if (parent.getTextAttributes() != null) {
}
/** write our attributes and content */
- protected void writeRtfContent() throws IOException
- {
+ protected void writeRtfContent() throws IOException {
writeGroupMark(true);
writeControlWord(RTF_FIELD);
writeGroupMark(true);
- writeAttributes(m_attrib,RtfText.ATTR_NAMES); // Added by Boris Poudérous
+ writeAttributes(m_attrib, RtfText.ATTR_NAMES); // Added by Boris Poudérous
writeStarControlWord(RTF_FIELD_PAGE);
writeGroupMark(false);
writeGroupMark(true);
}
/** true if this element would generate no "useful" RTF content */
- public boolean isEmpty()
- {
+ public boolean isEmpty() {
return false;
}
}
* @author Boris Pouderous, boris.pouderous@free.fr
*/
-public class RtfPageNumberCitation extends RtfContainer
-{
+public class RtfPageNumberCitation extends RtfContainer {
// Page field :
// "{\field {\*\fldinst {PAGEREF xx}} {\fldrslt}}" where xx represents the
// 'id' of the referenced page
private String id = null;
/** Create an RTF page number citation as a child of given container with default attributes */
- RtfPageNumberCitation (IRtfPageNumberCitationContainer parent, Writer w, String id) throws IOException
- {
- super((RtfContainer)parent,w);
+ RtfPageNumberCitation (IRtfPageNumberCitationContainer parent, Writer w, String id)
+ throws IOException {
+ super((RtfContainer)parent, w);
this.id = id;
}
/** Create an RTF page number citation as a child of given
* paragraph, copying its attributes */
RtfPageNumberCitation (RtfParagraph parent, Writer w, String id)
- throws IOException
- {
+ throws IOException {
// add the attributes ant text attributes of the parent paragraph
- super((RtfContainer)parent,w, parent.m_attrib);
+ super((RtfContainer)parent, w, parent.m_attrib);
if (parent.getTextAttributes() != null) {
m_attrib.set(parent.getTextAttributes());
}
this.id = id;
}
- protected void writeRtfContent() throws IOException
- {
+ protected void writeRtfContent() throws IOException {
// If we have a valid ID
if (isValid()) {
// Build page reference field
String pageRef = RTF_FIELD_PAGEREF_MODEL;
final int insertionIndex = pageRef.indexOf("}");
pageRef =
- pageRef.substring(0,insertionIndex) + "\"" + id + "\"" + " "
+ pageRef.substring(0, insertionIndex) + "\"" + id + "\"" + " "
+ pageRef.substring(insertionIndex, pageRef.length())
;
id = null;
writeGroupMark(true);
writeControlWord(RTF_FIELD);
writeGroupMark(true);
- writeAttributes(m_attrib,RtfText.ATTR_NAMES); // Added by Boris Poudérous
+ writeAttributes(m_attrib, RtfText.ATTR_NAMES); // Added by Boris Poudérous
writeStarControlWord(pageRef);
writeGroupMark(false);
writeGroupMark(true);
}
/** checks that the 'ref-id' attribute exists */
- private boolean isValid()
- {
- if (id != null)
+ private boolean isValid() {
+ if (id != null) {
return true;
- else
+ } else {
return false;
+ }
}
/** true if this element would generate no "useful" RTF content */
- public boolean isEmpty()
- {
+ public boolean isEmpty() {
return false;
}
}
*/
public class RtfParagraph extends RtfBookmarkContainerImpl
-implements IRtfTextContainer,IRtfPageBreakContainer,IRtfHyperLinkContainer,IRtfExternalGraphicContainer,
-IRtfPageNumberContainer,IRtfPageNumberCitationContainer {
+implements IRtfTextContainer, IRtfPageBreakContainer, IRtfHyperLinkContainer,
+ IRtfExternalGraphicContainer, IRtfPageNumberContainer,
+ IRtfPageNumberCitationContainer {
private RtfText m_text;
private RtfHyperLink m_hyperlink;
private RtfExternalGraphic m_externalGraphic;
private RtfPageNumber m_pageNumber;
- private RtfPageNumberCitation m_pageNumberCitation; // Line added by Boris POUDEROUS on 2002/07/09
- private boolean m_keepn=false;
- private boolean m_resetProperties=false;
+ private RtfPageNumberCitation m_pageNumberCitation;
+ // Above line added by Boris POUDEROUS on 2002/07/09
+ private boolean m_keepn = false;
+ private boolean m_resetProperties = false;
/* needed for importing Rtf into FrameMaker
FrameMaker is not as forgiving as word in rtf
/** Create an RTF paragraph as a child of given container with default attributes */
RtfParagraph(IRtfParagraphContainer parent, Writer w) throws IOException {
- super((RtfContainer)parent,w);
+ super((RtfContainer)parent, w);
}
/** Create an RTF paragraph as a child of given container with given attributes */
- RtfParagraph(IRtfParagraphContainer parent, Writer w,RtfAttributes attr) throws IOException {
- super((RtfContainer)parent,w,attr);
+ RtfParagraph(IRtfParagraphContainer parent, Writer w, RtfAttributes attr) throws IOException {
+ super((RtfContainer)parent, w, attr);
}
- public String getText(){
- return(m_text.getText());
+ public String getText() {
+ return (m_text.getText());
}
/** Set the keepn attribute for this paragraph */
public void setKeepn() {
- this.m_keepn=true;
+ this.m_keepn = true;
}
/** Force reset properties */
public void setResetProperties() {
- this.m_resetProperties=true;
+ this.m_resetProperties = true;
}
/** IRtfTextContainer requirement: return a copy of our attributes */
public RtfAttributes getTextContainerAttributes() {
- if(m_attrib == null) return null;
+ if (m_attrib == null) {
+ return null;
+ }
return (RtfAttributes)this.m_attrib.clone();
}
protected void writeRtfPrefix() throws IOException {
// collapse whitespace before writing out
// TODO could be made configurable
- if(m_attrib != null && m_attrib.isSet("WhiteSpaceFalse")){
+ if (m_attrib != null && m_attrib.isSet("WhiteSpaceFalse")) {
m_attrib.unset("WhiteSpaceFalse");
} else {
new WhitespaceCollapser(this);
}
//Reset paragraph properties if needed
- if(m_resetProperties) {
+ if (m_resetProperties) {
writeControlWord("pard");
}
// do not write text attributes here, they are handled
// by RtfText
- writeAttributes(m_attrib,PARA_ATTRIBUTES);
+ writeAttributes(m_attrib, PARA_ATTRIBUTES);
// Added by Normand Masse
// Write alignment attributes after \intbl for cells
- if ( m_attrib.isSet( "intbl" ) && mustWriteAttributes() ) {
+ if (m_attrib.isSet("intbl") && mustWriteAttributes()) {
writeAttributes(m_attrib, RtfText.ALIGNMENT);
}
//Set keepn if needed (Keep paragraph with the next paragraph)
- if(m_keepn) writeControlWord("keepn");
+ if (m_keepn) {
+ writeControlWord("keepn");
+ }
// start a group for this paragraph and write our own attributes if needed
- if(mustWriteGroupMark()) writeGroupMark(true);
+ if (mustWriteGroupMark()) {
+ writeGroupMark(true);
+ }
- if(mustWriteAttributes()) {
+ if (mustWriteAttributes()) {
// writeAttributes(m_attrib, new String [] {"cs"});
// Added by Normand Masse
// If \intbl then attributes have already been written (see higher in method)
- if ( !m_attrib.isSet( "intbl" ) ) {
+ if (!m_attrib.isSet("intbl")) {
writeAttributes(m_attrib, RtfText.ALIGNMENT);
}
//this line added by Chris Scott, Westinghouse
writeAttributes(m_attrib, RtfText.BORDER);
writeAttributes(m_attrib, RtfText.INDENT);
writeAttributes(m_attrib, RtfText.TABS);
- if(writeForBreak){
+ if (writeForBreak) {
writeControlWord("pard\\par");
}
}
protected void writeRtfSuffix() throws IOException {
// sometimes the end of paragraph mark must be suppressed in table cells
boolean writeMark = true;
- if(m_parent instanceof RtfTableCell) {
+ if (m_parent instanceof RtfTableCell) {
writeMark = ((RtfTableCell)m_parent).paragraphNeedsPar(this);
}
- if(writeMark) {
+ if (writeMark) {
writeControlWord("par");
}
- if(mustWriteGroupMark()) writeGroupMark(false);
+ if (mustWriteGroupMark()) {
+ writeGroupMark(false);
+ }
}
* @param str if not null, added to the RtfText created
*/
public RtfText newText(String str) throws IOException {
- return newText(str,null);
+ return newText(str, null);
}
/** close current text run if any and start a new one
* @param str if not null, added to the RtfText created
*/
- public RtfText newText(String str,RtfAttributes attr) throws IOException {
+ public RtfText newText(String str, RtfAttributes attr) throws IOException {
closeAll();
- m_text = new RtfText(this,m_writer,str,attr);
+ m_text = new RtfText(this, m_writer, str, attr);
return m_text;
}
/** add a page break */
public void newPageBreak() throws IOException {
writeForBreak = true;
- new RtfPageBreak(this,m_writer);
+ new RtfPageBreak(this, m_writer);
}
/** add a line break */
public void newLineBreak() throws IOException {
- new RtfLineBreak(this,m_writer);
+ new RtfLineBreak(this, m_writer);
}
public RtfPageNumber newPageNumber()throws IOException {
- m_pageNumber = new RtfPageNumber(this,m_writer);
+ m_pageNumber = new RtfPageNumber(this, m_writer);
return m_pageNumber;
}
/**
* Added by Boris POUDEROUS on 2002/07/09
*/
- public RtfPageNumberCitation newPageNumberCitation(String id) throws IOException
- {
- m_pageNumberCitation = new RtfPageNumberCitation(this,m_writer, id);
+ public RtfPageNumberCitation newPageNumberCitation(String id) throws IOException {
+ m_pageNumberCitation = new RtfPageNumberCitation(this, m_writer, id);
return m_pageNumberCitation;
}
/** start a new external graphic after closing all other elements */
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 closeCurrentText() throws IOException {
- if(m_text != null) m_text.close();
+ if (m_text != null) {
+ m_text.close();
+ }
}
private void closeCurrentHyperLink() throws IOException {
- if(m_hyperlink != null) m_hyperlink.close();
+ if (m_hyperlink != null) {
+ m_hyperlink.close();
+ }
}
private void closeAll() throws IOException {
protected boolean okToWriteRtf() {
boolean result = super.okToWriteRtf();
- if(m_parent.getOptions().ignoreEmptyParagraphs() && getChildCount() == 0) {
+ if (m_parent.getOptions().ignoreEmptyParagraphs() && getChildCount() == 0) {
// TODO should test that this is the last RtfParagraph in the cell instead
// of simply testing for last child??
result = false;
final List childList = getChildren();
for (int i = 0; i < children; i++) {
final RtfElement el = (RtfElement) childList.get(i);
- if (! el.isEmpty()) {
- if (el.getClass() == RtfText.class ) {
+ if (!el.isEmpty()) {
+ if (el.getClass() == RtfText.class) {
boolean tmp = ((RtfText) el).isNbsp();
- if (! tmp) {
+ if (!tmp) {
writeAttributes = true;
break;
}
- }
- else {
+ } else {
writeAttributes = true;
break;
}
}
/** true if we must write a group mark around this paragraph
- * TODO is this correct, study interaction with mustWriteAttributes() <-- On implementation i have noticed if the groupmark set, the format attributes are only for this content, i think this implementation is ok
+ * TODO is this correct, study interaction with mustWriteAttributes()
+ * <-- On implementation i have noticed if the groupmark set, the
+ * format attributes are only for this content, i think this
+ * implementation is ok
*/
private boolean mustWriteGroupMark() {
return getChildCount() > 0;
}
/** get the attributes of our text */
- public RtfAttributes getTextAttributes(){
- if(m_text == null) return null;
+ public RtfAttributes getTextAttributes() {
+ if (m_text == null) {
+ return null;
+ }
return m_text.getTextAttributes();
}
}
import java.io.Writer;
-import java.io.*;
-import java.util.*;
import java.io.IOException;
-public class RtfParagraphKeepTogether extends RtfContainer{
+public class RtfParagraphKeepTogether extends RtfContainer {
- public static final int STATUS_NULL=0;
- public static final int STATUS_OPEN_PARAGRAPH=1;
- public static final int STATUS_CLOSE_PARAGRAPH=2;
- private int m_status =STATUS_NULL;
+ public static final int STATUS_NULL = 0;
+ public static final int STATUS_OPEN_PARAGRAPH = 1;
+ public static final int STATUS_CLOSE_PARAGRAPH = 2;
+ private int m_status = STATUS_NULL;
/** RtfParagraphKeepTogether*/
RtfParagraphKeepTogether(IRtfParagraphContainer parent, Writer w) throws IOException {
- super((RtfContainer)parent,w);
+ super((RtfContainer)parent, w);
}
//First reet paragraph properties
// create a new one with keepn
- if (m_status==STATUS_OPEN_PARAGRAPH) {
+ if (m_status == STATUS_OPEN_PARAGRAPH) {
writeControlWord("pard");
writeControlWord("par");
writeControlWord("keepn");
}
/** true if this element would generate no "useful" RTF content */
- public boolean isEmpty()
- {
+ public boolean isEmpty() {
return false;
}
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;
IRtfBeforeContainer,
IRtfParagraphKeepTogetherContainer,
IRtfAfterContainer,
- IRtfJforCmdContainer
-{
+ IRtfJforCmdContainer {
private RtfParagraph m_paragraph;
private RtfTable m_table;
private RtfList m_list;
/** Create an RTF container as a child of given container */
RtfSection(RtfDocumentArea parent, Writer w) throws IOException {
- super(parent,w);
+ super(parent, w);
}
/** start a new external graphic after closing current paragraph, list and table */
public RtfExternalGraphic newImage() throws IOException {
closeAll();
- m_externalGraphic = new RtfExternalGraphic(this,m_writer);
+ m_externalGraphic = new RtfExternalGraphic(this, m_writer);
return m_externalGraphic;
}
/** start a new paragraph after closing current paragraph, list and table */
public RtfParagraph newParagraph(RtfAttributes attrs) throws IOException {
closeAll();
- m_paragraph = new RtfParagraph(this,m_writer,attrs);
+ m_paragraph = new RtfParagraph(this, m_writer, attrs);
return m_paragraph;
}
/** close current paragraph if any and start a new one */
public RtfParagraphKeepTogether newParagraphKeepTogether() throws IOException {
- return new RtfParagraphKeepTogether(this,m_writer);
+ return new RtfParagraphKeepTogether(this, m_writer);
}
/** start a new table after closing current paragraph, list and table
- * @param tc Table context used for number-columns-spanned attribute (added by Boris Poudérous on july 2002)
+ * @param tc Table context used for number-columns-spanned attribute (added by
+ * Boris Poudérous on july 2002)
*/
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;
}
/** start a new table after closing current paragraph, list and table
- * @param tc Table context used for number-columns-spanned attribute (added by Boris Poudérous on july 2002)
+ * @param tc Table context used for number-columns-spanned attribute (added by
+ * Boris Poudérous on july 2002)
*/
- public RtfTable newTable(RtfAttributes attrs, ITableColumnsInfo tc) throws IOException
- {
+ 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;
}
/** start a new list after closing current paragraph, list and table */
public RtfList newList(RtfAttributes attrs) throws IOException {
closeAll();
- m_list = new RtfList(this,m_writer, attrs);
+ m_list = new RtfList(this, m_writer, attrs);
return m_list;
}
/** IRtfBeforeContainer */
public RtfBefore newBefore(RtfAttributes attrs) throws IOException {
closeAll();
- m_before = new RtfBefore(this,m_writer,attrs);
+ m_before = new RtfBefore(this, m_writer, attrs);
return m_before;
}
/** IRtfAfterContainer */
public RtfAfter newAfter(RtfAttributes attrs) throws IOException {
closeAll();
- m_after = new RtfAfter(this,m_writer,attrs);
+ m_after = new RtfAfter(this, m_writer, attrs);
return m_after;
}
public RtfJforCmd newJforCmd(RtfAttributes attrs) throws IOException {
- m_jforCmd = new RtfJforCmd(this,m_writer,attrs);
+ m_jforCmd = new RtfJforCmd(this, m_writer, attrs);
return m_jforCmd;
}
}
private void closeCurrentTable() throws IOException {
- if(m_table != null) m_table.close();
+ if (m_table != null) {
+ m_table.close();
+ }
}
private void closeCurrentParagraph() throws IOException {
- if(m_paragraph!=null) m_paragraph.close();
+ if (m_paragraph != null) {
+ m_paragraph.close();
+ }
}
private void closeCurrentList() throws IOException {
- if(m_list!=null) m_list.close();
+ if (m_list != null) {
+ m_list.close();
+ }
}
private void closeCurrentExternalGraphic() throws IOException {
- if(m_externalGraphic!=null) m_externalGraphic.close();
+ if (m_externalGraphic != null) {
+ m_externalGraphic.close();
+ }
}
private void closeCurrentBefore() throws IOException {
- if(m_before!=null) m_before.close();
+ if (m_before != null) {
+ m_before.close();
+ }
}
private void closeAll()
package org.apache.fop.rtf.rtflib.rtfdoc;
-import java.util.*;
+import java.util.Map;
+import java.util.HashMap;
import java.io.IOException;
import java.io.Writer;
/** List of characters to escape with corresponding replacement strings */
static {
m_specialChars = new HashMap();
- m_specialChars.put(new Character('\t'),"tab");
- m_specialChars.put(new Character('\n'),"line");
- m_specialChars.put(new Character('\''),"rquote");
- m_specialChars.put(new Character('\"'),"rdblquote");
- m_specialChars.put(new Character('\\'),"\\");
- m_specialChars.put(new Character('{'),"{");
- m_specialChars.put(new Character('}'),"}");
+ m_specialChars.put(new Character('\t'), "tab");
+ m_specialChars.put(new Character('\n'), "line");
+ m_specialChars.put(new Character('\''), "rquote");
+ m_specialChars.put(new Character('\"'), "rdblquote");
+ m_specialChars.put(new Character('\\'), "\\");
+ m_specialChars.put(new Character('{'), "{");
+ m_specialChars.put(new Character('}'), "}");
}
/** singleton pattern */
}
/** write given String to given Writer, converting characters as required by RTF spec */
- public void writeRtfString(Writer w,String str) throws IOException {
- if(str == null) return;
+ public void writeRtfString(Writer w, String str) throws IOException {
+ if (str == null) {
+ return;
+ }
// TODO: could be made more efficient (binary lookup, etc.)
- for(int i=0; i < str.length(); i++) {
+ for (int i = 0; i < str.length(); i++) {
final Character c = new Character(str.charAt(i));
Character d;
String replacement;
- if(i!= 0) {
- d=new Character(str.charAt(i-1));
+ if (i != 0) {
+ d = new Character(str.charAt(i - 1));
} else {
- d=new Character(str.charAt(i));
+ d = new Character(str.charAt(i));
}
//This section modified by Chris Scott
//add "smart" quote recognition
- if(c.equals((Object)DBLQUOTE) && d.equals((Object)SPACE)) {
+ if (c.equals((Object)DBLQUOTE) && d.equals((Object)SPACE)) {
replacement = "ldblquote";
- } else if(c.equals((Object)QUOTE) && d.equals((Object)SPACE)) {
+ } else if (c.equals((Object)QUOTE) && d.equals((Object)SPACE)) {
replacement = "lquote";
} else {
replacement = (String)m_specialChars.get(c);
}
- if(replacement != null) {
+ if (replacement != null) {
// RTF-escaped char
w.write('\\');
w.write(replacement);
w.write(' ');
} else if (c.charValue() > 255) {
- // write unicode representation - contributed by Michel Jacobson <jacobson@idf.ext.jussieu.fr>
+ // write unicode representation - contributed by Michel Jacobson
+ // <jacobson@idf.ext.jussieu.fr>
w.write("\\u");
w.write(Integer.toString((int)c.charValue()));
w.write("\\\'3f");
* This class belongs to the <jfor:stylesheet> tag processing.
* @author <a href="mailto:a.putz@skynamics.com">Andreas Putz</a>
*/
-public class RtfStyleSheetTable
-{
+public class RtfStyleSheetTable {
//////////////////////////////////////////////////
// @@ Symbolic constants
//////////////////////////////////////////////////
/**
* Constructor.
*/
- private RtfStyleSheetTable ()
- {
+ private RtfStyleSheetTable () {
styles = new Hashtable ();
attrTable = new Hashtable ();
nameTable = new Vector ();
*
* @return The instance of RtfStyleSheetTable
*/
- public static RtfStyleSheetTable getInstance ()
- {
- if (instance == null)
- {
+ public static RtfStyleSheetTable getInstance () {
+ if (instance == null) {
instance = new RtfStyleSheetTable ();
}
* Sets the default style.
* @param styleName Name of the default style, defined in the stylesheet
*/
- public void setDefaultStyle (String styleName)
- {
+ public void setDefaultStyle (String styleName) {
this.defaultStyleName = styleName;
}
* Gets the name of the default style.
* @return Default style name.
*/
- public String getDefaultStyleName ()
- {
- if (attrTable.get (defaultStyleName) != null)
+ public String getDefaultStyleName () {
+ if (attrTable.get (defaultStyleName) != null) {
return defaultStyleName;
+ }
- if (attrTable.get (STANDARD_STYLE) != null)
- {
+ if (attrTable.get (STANDARD_STYLE) != null) {
defaultStyleName = STANDARD_STYLE;
return defaultStyleName;
}
* @param name Name of style to add
* @param attrs Rtf attributes which defines the style
*/
- public void addStyle (String name, RtfAttributes attrs)
- {
+ public void addStyle (String name, RtfAttributes attrs) {
nameTable.addElement (name);
- if (attrs != null)
+ if (attrs != null) {
attrTable.put (name, attrs);
+ }
styles.put (name, new Integer (nameTable.size () - 1 + startIndex));
}
/**
* Adds the style attributes to the given attributes.
* @param name Name of style, of which the attributes will copied to attr
- * @param attrs Default rtf attributes
+ * @param attr Default rtf attributes
* @return Status value
*/
- public int addStyleToAttributes (String name, RtfAttributes attr)
- {
+ public int addStyleToAttributes (String name, RtfAttributes attr) {
// Sets status to ok
int status = STATUS_OK;
// Gets the style number from table
Integer style = (Integer) styles.get (name);
- if (style == null && !name.equals (defaultStyleName))
- {
+ if (style == null && !name.equals (defaultStyleName)) {
// If style not found, and style was not the default style, try the default style
name = defaultStyleName;
style = (Integer) styles.get (name);
}
// Returns the status for invalid styles
- if (style == null)
+ if (style == null) {
return status;
+ }
// Adds the attributes to default attributes, if not available in default attributes
attr.set ("cs", style.intValue ());
Object o = attrTable.get (name);
- if (o != null)
- {
+ if (o != null) {
RtfAttributes rtfAttr = (RtfAttributes) o;
- for (Iterator names = rtfAttr.nameIterator (); names.hasNext ();)
- {
+ for (Iterator names = rtfAttr.nameIterator (); names.hasNext ();) {
String attrName = (String) names.next ();
- if (! attr.isSet (attrName))
- {
+ if (!attr.isSet (attrName)) {
Integer i = (Integer) rtfAttr.getValue (attrName);
- if (i == null)
+ if (i == null) {
attr.set (attrName);
- else
+ } else {
attr.set (attrName, i.intValue ());
+ }
}
}
}
* @param header Rtf header is the parent
* @throws IOException On write error
*/
- public void writeStyleSheet (RtfHeader header) throws IOException
- {
- if (styles == null || styles.size () == 0)
- {
+ public void writeStyleSheet (RtfHeader header) throws IOException {
+ if (styles == null || styles.size () == 0) {
return;
}
header.writeGroupMark (true);
header.writeControlWord ("stylesheet");
int number = nameTable.size ();
- for (int i = 0; i < number; i++)
- {
+ for (int i = 0; i < number; i++) {
String name = (String) nameTable.elementAt (i);
header.writeGroupMark (true);
header.writeControlWord ("*\\" + this.getRtfStyleReference (name));
Object o = attrTable.get (name);
- if (o != null)
- {
+ if (o != null) {
header.writeAttributes ((RtfAttributes) o, RtfText.ATTR_NAMES);
header.writeAttributes ((RtfAttributes) o, RtfText.ALIGNMENT);
}
* @param name Name of Style
* @return Rtf attribute of the style reference
*/
- private String getRtfStyleReference (String name)
- {
+ private String getRtfStyleReference (String name) {
return "cs" + styles.get (name).toString ();
}
}
\ No newline at end of file