(int)FoUnitsConverter.getInstance().convertToTwips(f.toString() + "pt"));
}
} catch (FOPException e) {
- log.error("Exception in convertPageAttributes: " + e.getMessage() + "- page attributes ignored");
- attrib=new RtfAttributes();
+ log.error("Exception in convertPageAttributes: "
+ + e.getMessage() + "- page attributes ignored");
+ attrib = new RtfAttributes();
}
return attrib;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.avalon.framework.logger.Logger;
import org.apache.fop.apps.FOPException;
-import org.apache.fop.datatypes.ColorType;
import org.apache.fop.fo.EnumProperty;
import org.apache.fop.fo.FOInputHandler;
import org.apache.fop.datatypes.FixedLength;
import org.apache.fop.fo.properties.Constants;
import org.apache.fop.fo.Property;
import org.apache.fop.fo.LengthProperty;
-import org.apache.fop.fo.PropertyList;
import org.apache.fop.apps.Document;
import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfAfterContainer;
import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfBeforeContainer;
-import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfExternalGraphicContainer;
-import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfPageNumberContainer;
-import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfParagraphContainer;
import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfTextrunContainer;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAfter;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfBefore;
-import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfColorTable;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfDocumentArea;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFile;
-import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFontManager;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfParagraph;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection;
-import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTextrun;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow;
private final Logger log = new ConsoleLogger();
private RtfSection sect;
private RtfDocumentArea docArea;
- private RtfParagraph para;
+ //private RtfParagraph para; //never used
private boolean warned = false;
private boolean bPrevHeaderSpecified = false;//true, if there has been a
//header in any page-sequence
//read page size and margins, if specified
Property prop;
- if((prop=pageSeq.properties.get("master-reference"))!=null) {
- String reference=prop.getString();
+ if ((prop = pageSeq.properties.get("master-reference")) != null) {
+ String reference = prop.getString();
- SimplePageMaster pagemaster=
- pageSeq.getLayoutMasterSet().getSimplePageMaster(reference);
+ SimplePageMaster pagemaster
+ = pageSeq.getLayoutMasterSet().getSimplePageMaster(reference);
//only simple-page-master supported, so pagemaster may be null
- if(pagemaster!=null) {
+ if (pagemaster != null) {
sect.getRtfAttributes().set(
PageAttributesConverter.convertPageAttributes(
- pagemaster.properties,null));
+ pagemaster.properties, null));
}
}
RtfAttributes attr = new RtfAttributes();
attr.set(RtfBefore.HEADER);
- final IRtfBeforeContainer contBefore =
- (IRtfBeforeContainer)builderContext.getContainer
+ final IRtfBeforeContainer contBefore
+ = (IRtfBeforeContainer)builderContext.getContainer
(IRtfBeforeContainer.class, true, this);
contBefore.newBefore(attr);
}
RtfAttributes attr = new RtfAttributes();
attr.set(RtfAfter.FOOTER);
- final IRtfAfterContainer contAfter =
- (IRtfAfterContainer)builderContext.getContainer
+ final IRtfAfterContainer contAfter
+ = (IRtfAfterContainer)builderContext.getContainer
(IRtfAfterContainer.class, true, this);
contAfter.newAfter(attr);
}
bHeaderSpecified = true;
bPrevHeaderSpecified = true;
- final IRtfBeforeContainer c =
- (IRtfBeforeContainer)builderContext.getContainer(IRtfBeforeContainer.class,
+ final IRtfBeforeContainer c
+ = (IRtfBeforeContainer)builderContext.getContainer(
+ IRtfBeforeContainer.class,
true, this);
RtfAttributes beforeAttributes = ((RtfElement)c).getRtfAttributes();
bFooterSpecified = true;
bPrevFooterSpecified = true;
- final IRtfAfterContainer c =
- (IRtfAfterContainer)builderContext.getContainer(IRtfAfterContainer.class,
+ final IRtfAfterContainer c
+ = (IRtfAfterContainer)builderContext.getContainer(
+ IRtfAfterContainer.class,
true, this);
RtfAttributes afterAttributes = ((RtfElement)c).getRtfAttributes();
*/
public void startBlock(Block bl) {
try {
- RtfAttributes rtfAttr =
- TextAttributesConverter.convertAttributes(bl.properties, null);
+ RtfAttributes rtfAttr
+ = TextAttributesConverter.convertAttributes(bl.properties, null);
- IRtfTextrunContainer container =
- (IRtfTextrunContainer)builderContext.getContainer(IRtfTextrunContainer.class,
- true,this);
+ IRtfTextrunContainer container
+ = (IRtfTextrunContainer)builderContext.getContainer(
+ IRtfTextrunContainer.class,
+ true, this);
- RtfTextrun textrun=container.getTextrun();
+ RtfTextrun textrun = container.getTextrun();
textrun.addParagraphBreak();
textrun.pushAttributes(rtfAttr);
*/
public void endBlock(Block bl) {
try {
- IRtfTextrunContainer container =
- (IRtfTextrunContainer)builderContext.getContainer(IRtfTextrunContainer.class,
- true,this);
+ IRtfTextrunContainer container
+ = (IRtfTextrunContainer)builderContext.getContainer(
+ IRtfTextrunContainer.class,
+ true, this);
- RtfTextrun textrun=container.getTextrun();
+ RtfTextrun textrun = container.getTextrun();
textrun.addParagraphBreak();
textrun.popAttributes();
TableContext tableContext = new TableContext(builderContext);
try {
- RtfAttributes atts =
- TableAttributesConverter.convertTableAttributes(tbl.properties);
+ RtfAttributes atts
+ = TableAttributesConverter.convertTableAttributes(tbl.properties);
- final IRtfTableContainer tc =
- (IRtfTableContainer)builderContext.getContainer(IRtfTableContainer.class,
- true, null);
+ final IRtfTableContainer tc
+ = (IRtfTableContainer)builderContext.getContainer(
+ IRtfTableContainer.class, true, null);
builderContext.pushContainer(tc.newTable(atts, tableContext));
} catch (Exception e) {
log.error("startTable:" + e.getMessage());
*
* @param inl Inline that is starting.
*/
- public void startInline(Inline inl){
+ public void startInline(Inline inl) {
try {
- RtfAttributes rtfAttr =
- TextAttributesConverter.convertCharacterAttributes(inl.properties, null);
+ RtfAttributes rtfAttr
+ = TextAttributesConverter.convertCharacterAttributes(inl.properties, null);
- IRtfTextrunContainer container =
- (IRtfTextrunContainer)builderContext.getContainer(IRtfTextrunContainer.class,
- true,this);
+ IRtfTextrunContainer container
+ = (IRtfTextrunContainer)builderContext.getContainer(
+ IRtfTextrunContainer.class, true, this);
- RtfTextrun textrun=container.getTextrun();
+ RtfTextrun textrun = container.getTextrun();
textrun.pushAttributes(rtfAttr);
} catch (IOException ioe) {
log.error("startInline:" + ioe.getMessage());
*
* @param inl Inline that is ending.
*/
- public void endInline(Inline inl){
+ public void endInline(Inline inl) {
try {
- IRtfTextrunContainer container =
- (IRtfTextrunContainer)builderContext.getContainer(IRtfTextrunContainer.class,
- true,this);
+ IRtfTextrunContainer container
+ = (IRtfTextrunContainer)builderContext.getContainer(
+ IRtfTextrunContainer.class, true, this);
- RtfTextrun textrun=container.getTextrun();
+ RtfTextrun textrun = container.getTextrun();
textrun.popAttributes();
} catch (IOException ioe) {
log.error("startInline:" + ioe.getMessage());
try {
- final IRtfTextrunContainer c =
- (IRtfTextrunContainer)builderContext.getContainer(IRtfTextrunContainer.class,
- true, this);
+ final IRtfTextrunContainer c
+ = (IRtfTextrunContainer)builderContext.getContainer(
+ IRtfTextrunContainer.class, true, this);
final RtfExternalGraphic newGraphic = c.getTextrun().newImage();
- Property p=null;
+ Property p = null;
//get source file
- if((p=eg.properties.get("src"))!=null) {
+ if ((p = eg.properties.get("src")) != null) {
newGraphic.setURL (p.getString());
} else {
log.error("The attribute 'src' of <fo:external-graphic> is required.");
}
//get scaling
- if((p=eg.properties.get("scaling"))!=null) {
- EnumProperty e=(EnumProperty)p;
- if(p.getEnum()==Constants.UNIFORM) {
+ if ((p = eg.properties.get("scaling")) != null) {
+ EnumProperty e = (EnumProperty)p;
+ if (p.getEnum() == Constants.UNIFORM) {
newGraphic.setScaling ("uniform");
}
}
//get width
- if((p=eg.properties.get("width"))!=null) {
- LengthProperty lengthProp=(LengthProperty)p;
- if(lengthProp.getLength() instanceof FixedLength) {
+ if ((p = eg.properties.get("width")) != null) {
+ LengthProperty lengthProp = (LengthProperty)p;
+ if (lengthProp.getLength() instanceof FixedLength) {
Float f = new Float(lengthProp.getLength().getValue() / 1000f);
String sValue = f.toString() + "pt";
newGraphic.setWidth(sValue);
}
//get height
- if((p=eg.properties.get("height"))!=null) {
- LengthProperty lengthProp=(LengthProperty)p;
- if(lengthProp.getLength() instanceof FixedLength) {
+ if ((p = eg.properties.get("height")) != null) {
+ LengthProperty lengthProp = (LengthProperty)p;
+ if (lengthProp.getLength() instanceof FixedLength) {
Float f = new Float(lengthProp.getLength().getValue() / 1000f);
String sValue = f.toString() + "pt";
newGraphic.setHeight(sValue);
// int compression = m_context.m_options.getRtfExternalGraphicCompressionRate ();
int compression = 0;
if (compression != 0) {
- if (! newGraphic.setCompressionRate (compression)) {
- log.warn("The compression rate " + compression + " is invalid. The value has to be between 1 and 100 %.");
+ if (!newGraphic.setCompressionRate(compression)) {
+ log.warn("The compression rate " + compression
+ + " is invalid. The value has to be between 1 and 100 %.");
}
}
- } catch(Exception e) {
+ } catch (Exception e) {
log.error("image: " + e.getMessage());
}
}
/**
* @see org.apache.fop.fo.FOInputHandler#characters(char[], int, int)
*/
- public void characters(char data[], int start, int length) {
+ public void characters(char[] data, int start, int length) {
try {
- IRtfTextrunContainer container =
- (IRtfTextrunContainer)builderContext.getContainer(IRtfTextrunContainer.class,
- true,this);
+ IRtfTextrunContainer container
+ = (IRtfTextrunContainer)builderContext.getContainer(
+ IRtfTextrunContainer.class, true, this);
- RtfTextrun textrun=container.getTextrun();
+ RtfTextrun textrun = container.getTextrun();
textrun.addString(new String(data, start, length));
} catch (IOException ioe) {
// FIXME could we throw Exception in all FOInputHandler events?
*/
public void startPageNumber(PageNumber pagenum) {
try {
- RtfAttributes rtfAttr =
- TextAttributesConverter.convertCharacterAttributes(pagenum.properties, null);
+ RtfAttributes rtfAttr
+ = TextAttributesConverter.convertCharacterAttributes(
+ pagenum.properties, null);
- IRtfTextrunContainer container =
- (IRtfTextrunContainer)builderContext.getContainer(IRtfTextrunContainer.class,
- true,this);
+ IRtfTextrunContainer container
+ = (IRtfTextrunContainer)builderContext.getContainer(
+ IRtfTextrunContainer.class, true, this);
- RtfTextrun textrun=container.getTextrun();
+ RtfTextrun textrun = container.getTextrun();
textrun.addPageNumber(rtfAttr);
} catch (IOException ioe) {
log.error("startPageNumber:" + ioe.getMessage());
* @throws ConverterException On convertion error
*/
static RtfAttributes convertTableAttributes(PropertyList properties)
- throws FOPException {
+ throws FOPException {
RtfAttributes attrib = new RtfAttributes();
- LengthProperty lengthProp=null;
+ LengthProperty lengthProp = null;
// margin-left
- lengthProp=(LengthProperty)properties.get("margin-left");
+ lengthProp = (LengthProperty)properties.get("margin-left");
if (lengthProp != null) {
Float f = new Float(lengthProp.getLength().getValue() / 1000f);
final String sValue = f.toString() + "pt";
package org.apache.fop.render.rtf;
-//XML
-import org.xml.sax.Attributes;
-
//FOP
import org.apache.avalon.framework.logger.Logger;
import org.apache.avalon.framework.logger.ConsoleLogger;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.EnumProperty;
-import org.apache.fop.fo.expr.NCnameProperty;
import org.apache.fop.fo.properties.Constants;
import org.apache.fop.fo.LengthProperty;
-import org.apache.fop.fo.ListProperty;
import org.apache.fop.fo.PropertyList;
-import org.apache.fop.fo.Property;
import org.apache.fop.fo.SpaceProperty;
import org.apache.fop.fo.ColorTypeProperty;
-import org.apache.fop.fo.NumberProperty;
import org.apache.fop.datatypes.ColorType;
//RTF
* @param props list of FO properites, which are to be converted
* @param props list of default FO properites (usally null)
*/
- public static RtfAttributes convertCharacterAttributes(PropertyList props, PropertyList defProps)
- throws FOPException {
+ public static RtfAttributes convertCharacterAttributes(
+ PropertyList props, PropertyList defProps) throws FOPException {
RtfAttributes attrib = null;
String fopValue = properties.get("font-family").getString();
if (fopValue != null) {
- rtfAttr.set(RtfText.ATTR_FONT_FAMILY, RtfFontManager.getInstance().getFontNumber(fopValue));
+ rtfAttr.set(RtfText.ATTR_FONT_FAMILY,
+ RtfFontManager.getInstance().getFontNumber(fopValue));
}
}
private static void attrBlockFontColor(PropertyList properties, RtfAttributes rtfAttr) {
// Cell background color
- ColorTypeProperty colorTypeProp=(ColorTypeProperty)properties.get("color");
- if(colorTypeProp != null) {
+ ColorTypeProperty colorTypeProp = (ColorTypeProperty)properties.get("color");
+ if (colorTypeProp != null) {
ColorType colorType = colorTypeProp.getColorType();
if (colorType != null) {
if (colorType.getAlpha() != 0
private static void attrBlockFontItalic(PropertyList properties, RtfAttributes rtfAttr) {
String fopValue = properties.get("font-style").getString();
- if(fopValue.equals("italic")) {
+ if (fopValue.equals("italic")) {
rtfAttr.set(RtfText.ATTR_ITALIC, 1);
} else {
rtfAttr.set(RtfText.ATTR_ITALIC, 0);
}
private static void attrBlockFontUnderline(PropertyList properties, RtfAttributes rtfAttr) {
- EnumProperty enumProp=(EnumProperty)properties.get("text-decoration");
- if(enumProp.getEnum()==Constants.UNDERLINE) {
+ EnumProperty enumProp = (EnumProperty)properties.get("text-decoration");
+ if (enumProp.getEnum() == Constants.UNDERLINE) {
rtfAttr.set(RtfText.ATTR_UNDERLINE, 1);
} else {
rtfAttr.set(RtfText.ATTR_UNDERLINE, 0);
}
private static void attrBlockSpaceBeforeAfter(PropertyList properties, RtfAttributes rtfAttr) {
- SpaceProperty spaceProp=null;
+ SpaceProperty spaceProp = null;
//space-before
- spaceProp=(SpaceProperty)properties.get("space-before");
- if(spaceProp!=null) {
- Float f = new Float(spaceProp.getLengthRange().getOptimum().getLength().getValue() / 1000f);
+ spaceProp = (SpaceProperty)properties.get("space-before");
+ if (spaceProp != null) {
+ Float f = new Float(
+ spaceProp.getLengthRange().getOptimum().getLength().getValue() / 1000f);
String sValue = f.toString() + "pt";
try {
rtfAttr.set(
RtfText.SPACE_BEFORE,
(int)FoUnitsConverter.getInstance().convertToTwips(sValue));
- } catch(FOPException fe) {
+ } catch (FOPException fe) {
log.warn("attrBlockSpaceBeforeAfter: " + fe.getMessage());
}
}
//space-after
- spaceProp=(SpaceProperty)properties.get("space-after");
- if(spaceProp!=null) {
- Float f = new Float(spaceProp.getLengthRange().getOptimum().getLength().getValue() / 1000f);
+ spaceProp = (SpaceProperty)properties.get("space-after");
+ if (spaceProp != null) {
+ Float f = new Float(
+ spaceProp.getLengthRange().getOptimum().getLength().getValue() / 1000f);
String sValue = f.toString() + "pt";
try {
rtfAttr.set(
RtfText.SPACE_AFTER,
(int)FoUnitsConverter.getInstance().convertToTwips(sValue));
- } catch(FOPException fe) {
+ } catch (FOPException fe) {
log.warn("attrBlockSpaceBeforeAfter: " + fe.getMessage());
}
}
private static void attrBlockMargins(PropertyList properties, RtfAttributes rtfAttr) {
try {
- LengthProperty lengthProp=null;
+ LengthProperty lengthProp = null;
// margin-left
- lengthProp=(LengthProperty)properties.get("margin-left");
+ lengthProp = (LengthProperty)properties.get("margin-left");
if (lengthProp != null) {
Float f = new Float(lengthProp.getLength().getValue() / 1000f);
String sValue = f.toString() + "pt";
}
// margin-right
- lengthProp=(LengthProperty)properties.get("margin-right");
+ lengthProp = (LengthProperty)properties.get("margin-right");
if (lengthProp != null) {
Float f = new Float(lengthProp.getLength().getValue() / 1000f);
String sValue = f.toString() + "pt";
} else {
rtfAttr.set(RtfText.RIGHT_INDENT_BODY, 0);
}
- } catch(FOPException fe) {
+ } catch (FOPException fe) {
log.warn("attrBlockSpaceBeforeAfter: " + fe.getMessage());
}
}
int fopValue = properties.get("text-align").getEnum();
String rtfValue = null;
switch (fopValue) {
- case Constants.CENTER: {
+ case Constants.CENTER:
rtfValue = RtfText.ALIGN_CENTER;
break;
- }
- case Constants.END: {
+ case Constants.END:
rtfValue = RtfText.ALIGN_RIGHT;
break;
- }
- case Constants.JUSTIFY: {
+ case Constants.JUSTIFY:
rtfValue = RtfText.ALIGN_JUSTIFIED;
break;
- }
- default: {
+ default:
rtfValue = RtfText.ALIGN_LEFT;
break;
- }
}
rtfAttr.set(rtfValue);
* This file is part of the RTF library of the FOP project.
*/
-
package org.apache.fop.render.rtf.rtflib.rtfdoc;
import java.io.IOException;
-import java.io.Writer;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Iterator;
-import java.io.IOException;
-import org.apache.fop.render.rtf.rtflib.exceptions.RtfStructureException;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTextrun;
/** Interface which enables an implementing class to contain linear text runs.
*/
public interface IRtfTextrunContainer {
- public RtfTextrun getTextrun() throws IOException;
+ RtfTextrun getTextrun() throws IOException;
}
*/
public interface ITableAttributes {
/** to process column spanning */
- public static final String COLUMN_SPAN = "number-columns-spanned";
+ String COLUMN_SPAN = "number-columns-spanned";
/** to process row spanning */
- public static final String ROW_SPAN = "number-rows-spanned";
+ String ROW_SPAN = "number-rows-spanned";
// RTF 1.5 attributes (word 97)
/** half the space between the cells of a table row in twips */
- public static final String ATTR_RTF_15_TRGAPH = "trgaph";
- public static final String ATTR_ROW_LEFT_INDENT = "trleft";
+ String ATTR_RTF_15_TRGAPH = "trgaph";
+ String ATTR_ROW_LEFT_INDENT = "trleft";
// RTF 1.6 Row and table attributes
/** table row padding, top */
- public static final String ATTR_ROW_PADDING_TOP = "trpaddt";
+ String ATTR_ROW_PADDING_TOP = "trpaddt";
/** table row padding, bottom */
- public static final String ATTR_ROW_PADDING_BOTTOM = "trpaddb";
+ String ATTR_ROW_PADDING_BOTTOM = "trpaddb";
/** table row padding, left */
- public static final String ATTR_ROW_PADDING_LEFT = "trpaddl";
+ String ATTR_ROW_PADDING_LEFT = "trpaddl";
/** table row padding, right */
- public static final String ATTR_ROW_PADDING_RIGHT = "trpaddr";
+ String ATTR_ROW_PADDING_RIGHT = "trpaddr";
/** table row padding, top */
- public static final String ATTR_ROW_U_PADDING_TOP = "trpaddft";
+ String ATTR_ROW_U_PADDING_TOP = "trpaddft";
/** table row padding, bottom */
- public static final String ATTR_ROW_U_PADDING_BOTTOM = "trpaddfb";
+ String ATTR_ROW_U_PADDING_BOTTOM = "trpaddfb";
/** table row padding, left */
- public static final String ATTR_ROW_U_PADDING_LEFT = "trpaddfl";
+ String ATTR_ROW_U_PADDING_LEFT = "trpaddfl";
/** table row padding, right */
- public static final String ATTR_ROW_U_PADDING_RIGHT = "trpaddfr";
+ String ATTR_ROW_U_PADDING_RIGHT = "trpaddfr";
/**
* List of ALL ROW PADDING attributes, used to select them when writing
* attributes
*/
- public static final String[] ATTRIB_ROW_PADDING = {
+ String[] ATTRIB_ROW_PADDING = {
ATTR_ROW_PADDING_TOP, ATTR_ROW_U_PADDING_TOP,
ATTR_ROW_PADDING_BOTTOM, ATTR_ROW_U_PADDING_BOTTOM,
ATTR_ROW_PADDING_LEFT, ATTR_ROW_U_PADDING_LEFT,
// Cell attributes
/** cell padding, top */
- public static final String ATTR_CELL_PADDING_TOP = "clpadt";
+ String ATTR_CELL_PADDING_TOP = "clpadt";
/** cell padding, bottom */
- public static final String ATTR_CELL_PADDING_BOTTOM = "clpadb";
+ String ATTR_CELL_PADDING_BOTTOM = "clpadb";
/** cell padding, left */
- public static final String ATTR_CELL_PADDING_LEFT = "clpadl";
+ String ATTR_CELL_PADDING_LEFT = "clpadl";
/** cell padding, right */
- public static final String ATTR_CELL_PADDING_RIGHT = "clpadr";
+ String ATTR_CELL_PADDING_RIGHT = "clpadr";
/** cell padding, top */
- public static final String ATTR_CELL_U_PADDING_TOP = "clpadft";
+ String ATTR_CELL_U_PADDING_TOP = "clpadft";
/** cell padding, bottom */
- public static final String ATTR_CELL_U_PADDING_BOTTOM = "clpadfb";
+ String ATTR_CELL_U_PADDING_BOTTOM = "clpadfb";
/** cell padding, left */
- public static final String ATTR_CELL_U_PADDING_LEFT = "clpadfl";
+ String ATTR_CELL_U_PADDING_LEFT = "clpadfl";
/** cell padding, right */
- public static final String ATTR_CELL_U_PADDING_RIGHT = "clpadfr";
+ String ATTR_CELL_U_PADDING_RIGHT = "clpadfr";
// for border style file
/** cell border, top */
- public static final String CELL_BORDER_TOP = "clbrdrt";
+ String CELL_BORDER_TOP = "clbrdrt";
/** cell border, bottom */
- public static final String CELL_BORDER_BOTTOM = "clbrdrb";
+ String CELL_BORDER_BOTTOM = "clbrdrb";
/** cell border, left */
- public static final String CELL_BORDER_LEFT = "clbrdrl";
+ String CELL_BORDER_LEFT = "clbrdrl";
/** cell border, right */
- public static final String CELL_BORDER_RIGHT = "clbrdrr";
+ String CELL_BORDER_RIGHT = "clbrdrr";
//Table row border attributes
/** row border, top */
- public static final String ROW_BORDER_TOP = "trbrdrt";
+ String ROW_BORDER_TOP = "trbrdrt";
/** row border, bottom */
- public static final String ROW_BORDER_BOTTOM = "trbrdrb";
+ String ROW_BORDER_BOTTOM = "trbrdrb";
/** row border, left */
- public static final String ROW_BORDER_LEFT = "trbrdrl";
+ String ROW_BORDER_LEFT = "trbrdrl";
/** row border, right */
- public static final String ROW_BORDER_RIGHT = "trbrdrr";
+ String ROW_BORDER_RIGHT = "trbrdrr";
/** row border, horizontal */
- public static final String ROW_BORDER_HORIZONTAL = "trbrdrh";
+ String ROW_BORDER_HORIZONTAL = "trbrdrh";
/** row border, vertical */
- public static final String ROW_BORDER_VERTICAL = "trbrdrv";
+ String ROW_BORDER_VERTICAL = "trbrdrv";
//Table row attributes
/** row attribute, keep-together */
- public static final String ROW_KEEP_TOGETHER = "trkeep";
- public static final String ROW_HEIGHT = "trrh";
+ String ROW_KEEP_TOGETHER = "trkeep";
+ String ROW_HEIGHT = "trrh";
/**
* This control word is nonexistent in RTF, used to simulate the
* FO:keep-with-next attribute.
*/
- public static final String ROW_KEEP_WITH_NEXT = "knext";
+ String ROW_KEEP_WITH_NEXT = "knext";
/**
* This control word is nonexistent in RTF, used to simulate the
* FO:keep-with-previous attribute.
*/
- public static final String ROW_KEEP_WITH_PREVIOUS = "kprevious";
+ String ROW_KEEP_WITH_PREVIOUS = "kprevious";
/** cell shading, a unit-based attribute */
- public static final String CELL_SHADE = "clshdng";
+ String CELL_SHADE = "clshdng";
/** cell background color, a unit-based attribute */
- public static final String CELL_COLOR_BACKGROUND = "clcbpat";
+ String CELL_COLOR_BACKGROUND = "clcbpat";
/** cell foreground color, a unit-based attribute */
- public static final String CELL_COLOR_FOREGROUND = "clcfpat";
+ String CELL_COLOR_FOREGROUND = "clcfpat";
/**
* List of ALL CELL PADDING attributes, used to select them when writing
* attributes
*/
- public static final String[] ATTRIB_CELL_PADDING = {
+ String[] ATTRIB_CELL_PADDING = {
ATTR_CELL_PADDING_TOP, ATTR_CELL_U_PADDING_TOP,
ATTR_CELL_PADDING_BOTTOM, ATTR_CELL_U_PADDING_BOTTOM,
ATTR_CELL_PADDING_LEFT, ATTR_CELL_U_PADDING_LEFT,
* List of ALL CELL BORDER attributes, used to select them when writing
* attributes
*/
- public static final String[] CELL_BORDER = {
+ String[] CELL_BORDER = {
CELL_BORDER_TOP, CELL_BORDER_BOTTOM,
CELL_BORDER_LEFT, CELL_BORDER_RIGHT
};
* List of ALL ROW BORDER attributes, used to select them when writing
* attributes
*/
- public static final String[] ROW_BORDER = {
+ String[] ROW_BORDER = {
ROW_BORDER_TOP, ROW_BORDER_BOTTOM, ROW_BORDER_LEFT,
ROW_BORDER_RIGHT, ROW_BORDER_HORIZONTAL, ROW_BORDER_VERTICAL
};
* List of ALL CELL SHADING AND COLOR attributes, used to select them when
* writing attributes
*/
- public static final String[] CELL_COLOR = {
+ String[] CELL_COLOR = {
CELL_SHADE, CELL_COLOR_BACKGROUND, CELL_COLOR_FOREGROUND
};
}
\ No newline at end of file
* @param args command-line arguments
* @throws Exception for problems
*/
- public static void main(String args[])
+ public static void main(String[] args)
throws Exception {
Writer w = null;
if (args.length != 0) {
// Build page reference field
String pageRef = RTF_FIELD_PAGEREF_MODEL;
final int insertionIndex = pageRef.indexOf("}");
- pageRef =
- pageRef.substring(0, insertionIndex) + "\"" + id + "\"" + " "
- + pageRef.substring(insertionIndex, pageRef.length())
- ;
+ pageRef = pageRef.substring(0, insertionIndex)
+ + "\"" + id
+ + "\"" + " "
+ + pageRef.substring(insertionIndex, pageRef.length());
id = null;
// Write RTF content
private boolean writeForBreak = false;
/** Set of attributes that must be copied at the start of a paragraph */
- private static final String [] PARA_ATTRIBUTES = { "intbl" };
+ private static final String[] PARA_ATTRIBUTES = {"intbl"};
/** Create an RTF paragraph as a child of given container with default attributes */
RtfParagraph(IRtfParagraphContainer parent, Writer w) throws IOException {
* @author Peter Herweg, pherweg@web.de
*/
-public class RtfString extends RtfElement
-{
- String text="";
+public class RtfString extends RtfElement {
+ private String text = "";
RtfString(RtfContainer parent, Writer w, String s)
throws IOException {
super(parent, w);
- text=s;
+ text = s;
}
/**
}
public void setText(String s) {
- text=s;
+ text = s;
}
}
\ No newline at end of file
if (parent.parent instanceof RtfTable) {
// Get the context of the current table in order to get the width of each column
- ITableColumnsInfo tableColumnsInfo =
- ((RtfTable)parent.parent).getITableColumnsInfo();
+ ITableColumnsInfo tableColumnsInfo
+ = ((RtfTable)parent.parent).getITableColumnsInfo();
tableColumnsInfo.selectFirstColumn();
// Reach the column index in table context corresponding to the current column cell
RtfAttributes attrs = new RtfAttributes();
attrs.set("intbl");
- RtfTextrun textrun=RtfTextrun.getTextrun(this, writer, attrs);
+ RtfTextrun textrun = RtfTextrun.getTextrun(this, writer, attrs);
//Suppress the very last \par, because the closing \cell applies the
//paragraph attributes.
writeAttributes(attrib, ITableAttributes.CELL_BORDER);
writeAttributes(attrib, BorderAttributesConverter.BORDERS);
- if(attrib.isSet(ITableAttributes.ROW_HEIGHT)) {
+ if (attrib.isSet(ITableAttributes.ROW_HEIGHT)) {
writeOneAttribute(
ITableAttributes.ROW_HEIGHT,
attrib.getValue(ITableAttributes.ROW_HEIGHT));
nestedTableFound = true;
indexesFound.addElement(new Integer(index));
} else if (subElement instanceof RtfParagraph) {
- for (Iterator it3 =
- ((RtfParagraph)subElement).getChildren().iterator(); it3.hasNext();)
- {
+ for (Iterator it3
+ = ((RtfParagraph)subElement).getChildren().iterator();
+ it3.hasNext();) {
final RtfElement subSubElement = (RtfElement)it3.next();
if (subSubElement instanceof RtfTable) {
nestedTableFound = true;
import java.io.IOException;
import java.io.Writer;
-import java.util.LinkedList;
import java.util.List;
import java.util.Iterator;
-import java.io.IOException;
-import org.apache.fop.render.rtf.rtflib.exceptions.RtfStructureException;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfExternalGraphic;
-/** Class which contains a linear text run. It has methods to add attributes, text, paragraph breaks....
- * @author Peter Herweg, pherweg@web.de
+/**
+ * Class which contains a linear text run. It has methods to add attributes,
+ * text, paragraph breaks....
+ * @author Peter Herweg, pherweg@web.de
*/
-
public class RtfTextrun extends RtfContainer {
- private boolean bSuppressLastPar=false;
+ private boolean bSuppressLastPar = false;
/** Class which represents the opening of a RTF group mark.*/
- private class RtfOpenGroupMark extends RtfElement
- {
+ private class RtfOpenGroupMark extends RtfElement {
+
RtfOpenGroupMark(RtfContainer parent, Writer w, RtfAttributes attr)
- throws IOException {
+ throws IOException {
super(parent, w, attr);
}
}
/** Class which represents the closing of a RTF group mark.*/
- private class RtfCloseGroupMark extends RtfElement
- {
+ private class RtfCloseGroupMark extends RtfElement {
+
RtfCloseGroupMark(RtfContainer parent, Writer w)
- throws IOException {
+ throws IOException {
super(parent, w);
}
}
/** Class which represents a paragraph break.*/
- private class RtfParagraphBreak extends RtfElement
- {
+ private class RtfParagraphBreak extends RtfElement {
+
RtfParagraphBreak(RtfContainer parent, Writer w)
- throws IOException {
+ throws IOException {
super(parent, w);
}
}
public void pushAttributes(RtfAttributes attrs) throws IOException {
- RtfOpenGroupMark r=new RtfOpenGroupMark(this, writer, attrs);
+ RtfOpenGroupMark r = new RtfOpenGroupMark(this, writer, attrs);
}
public void popAttributes() throws IOException {
- RtfCloseGroupMark r=new RtfCloseGroupMark(this, writer);
+ RtfCloseGroupMark r = new RtfCloseGroupMark(this, writer);
}
public void addString(String s) throws IOException {
- RtfString r=new RtfString(this, writer, s);
+ RtfString r = new RtfString(this, writer, s);
}
public void addParagraphBreak() throws IOException {
- RtfParagraphBreak r=new RtfParagraphBreak(this, writer);
+ RtfParagraphBreak r = new RtfParagraphBreak(this, writer);
}
public void addPageNumber(RtfAttributes attr) throws IOException {
- RtfPageNumber r=new RtfPageNumber(this, writer, attr);
+ RtfPageNumber r = new RtfPageNumber(this, writer, attr);
}
public RtfExternalGraphic newImage() throws IOException {
* @throws IOException for I/O problems
*/
public static RtfTextrun getTextrun(RtfContainer container, Writer writer, RtfAttributes attrs)
- throws IOException {
+ throws IOException {
Object obj;
- List list=container.getChildren();
+ List list = container.getChildren();
- if(list.size()==0) {
+ if (list.size() == 0) {
//add a new RtfTextrun
- RtfTextrun textrun=new RtfTextrun(container, writer, attrs);
+ RtfTextrun textrun = new RtfTextrun(container, writer, attrs);
list.add(textrun);
return textrun;
- } else if ((obj=list.get(list.size()-1)) instanceof RtfTextrun ) {
+ } else if ((obj = list.get(list.size() - 1)) instanceof RtfTextrun ) {
//if the last child is a RtfTextrun, return it
return (RtfTextrun)obj;
}
//add a new RtfTextrun as the last child
- RtfTextrun textrun=new RtfTextrun(container, writer, attrs);
+ RtfTextrun textrun = new RtfTextrun(container, writer, attrs);
list.add(textrun);
return textrun;
/**
* specify, if the last paragraph control word (\par) should be suppressed.
* @param bSuppress true, if the last \par should be suppressed
- * @throws IOException for I/O problems
*/
public void setSuppressLastPar(boolean bSuppress) {
- bSuppressLastPar=bSuppress;
+ bSuppressLastPar = bSuppress;
}
/**
}
//determine, if this RtfTextrun is the last child of its parent
- boolean bLast=false;
+ boolean bLast = false;
for (Iterator it = parent.getChildren().iterator(); it.hasNext();) {
- if(it.next() == this) {
- bLast=!it.hasNext();
+ if (it.next() == this) {
+ bLast = !it.hasNext();
break;
}
}
//get last RtfParagraphBreak, which is not followed by any visible child
- RtfParagraphBreak lastParagraphBreak=null;
- if(bLast) {
+ RtfParagraphBreak lastParagraphBreak = null;
+ if (bLast) {
for (Iterator it = getChildren().iterator(); it.hasNext();) {
final RtfElement e = (RtfElement)it.next();
- if(e instanceof RtfParagraphBreak) {
- lastParagraphBreak=(RtfParagraphBreak)e;
+ if (e instanceof RtfParagraphBreak) {
+ lastParagraphBreak = (RtfParagraphBreak)e;
} else {
- if(!(e instanceof RtfOpenGroupMark)
- && !(e instanceof RtfCloseGroupMark)
- && e.isEmpty()) {
- lastParagraphBreak=null;
+ if (!(e instanceof RtfOpenGroupMark)
+ && !(e instanceof RtfCloseGroupMark)
+ && e.isEmpty()) {
+ lastParagraphBreak = null;
}
}
}
* -If the RtfTextrun is the last child of its parent, write a
* RtfParagraphBreak only, if it is not the last child.
*/
- boolean bHide=false;
- bHide=bRtfParagraphBreak;
- bHide=bHide &&
- (bPrevPar || bFirst ||
- (bSuppressLastPar && bLast && lastParagraphBreak!=null && e==lastParagraphBreak)
- );
+ boolean bHide = false;
+ bHide = bRtfParagraphBreak;
+ bHide = bHide
+ && (bPrevPar
+ || bFirst
+ || (bSuppressLastPar && bLast && lastParagraphBreak != null
+ && e == lastParagraphBreak));
- if( !bHide) {
+ if (!bHide) {
e.writeRtf();
}
- if(e instanceof RtfParagraphBreak) {
- bPrevPar=true;
- } else if(e instanceof RtfCloseGroupMark) {
+ if (e instanceof RtfParagraphBreak) {
+ bPrevPar = true;
+ } else if (e instanceof RtfCloseGroupMark) {
//do nothing
- } else if(e instanceof RtfOpenGroupMark) {
+ } else if (e instanceof RtfOpenGroupMark) {
//do nothing
} else {
- bPrevPar=bPrevPar && e.isEmpty();
- bFirst=bFirst && e.isEmpty();
+ bPrevPar = bPrevPar && e.isEmpty();
+ bFirst = bFirst && e.isEmpty();
}
}
}
/** process one RtfText from our container */
private void processText(RtfText txt) {
- final String newString=processString(txt.getText());
- if(newString!=null) {
+ final String newString = processString(txt.getText());
+ if (newString != null) {
txt.setText(newString);
}
}
/** process one RtfString from our container */
private void processString(RtfString txt) {
- final String newString=processString(txt.getText());
- if(newString!=null) {
+ final String newString = processString(txt.getText());
+ if (newString != null) {
txt.setText(newString);
}
}
// tokenize the text based on whitespace and regenerate it so as
// to collapse multiple spaces into one
- if(orig==null) {
+ if (orig == null) {
return null;
} else if (orig.length() > 0) {
final boolean allSpaces = orig.trim().length() == 0;
* @param args String array of arguments
* @throws Exception for errors
*/
- public static void main(String args[])
+ public static void main(String[] args)
throws Exception {
if (args.length < 1) {
System.err.println("usage: CreateTestDocuments <output directory>");