* A RtfAttributes subclass that adds some helper set methods.
*/
public class FOPRtfAttributes extends RtfAttributes {
+
+ /**
+ * Set an attribute that has a Length value (internal units in twips)
+ * @param name name of attribute
+ * @param value value of attribute
+ * @return this (which now contains the new entry)
+ */
+ public RtfAttributes setTwips(String name, Length value) {
+ set(name, value.getValue() / (1000 / 20)); //Convert millipoints to twips
+ return this;
+ }
+
/**
- * Set an attribute that has a Length value
+ * Set an attribute that has a Length value (internal units in half-points)
* @param name name of attribute
* @param value value of attribute
* @return this (which now contains the new entry)
*/
- public RtfAttributes set(String name, Length value) {
+ public RtfAttributes setHalfPoints(String name, Length value) {
set(name, value.getValue() / (1000 / 2)); //Convert millipoints to half-points
return this;
}
FOPRtfAttributes attrib = new FOPRtfAttributes();
- attrib.set(RtfListTable.LIST_INDENT, fobj.getCommonMarginBlock().startIndent);
- attrib.set(RtfText.LEFT_INDENT_BODY, fobj.getCommonMarginBlock().endIndent);
+ attrib.setTwips(RtfListTable.LIST_INDENT, fobj.getCommonMarginBlock().startIndent);
+ attrib.setTwips(RtfText.LEFT_INDENT_BODY, fobj.getCommonMarginBlock().endIndent);
/*
* set list table defaults
RegionBody body = (RegionBody) pagemaster.getRegion(Constants.FO_REGION_BODY);
RegionBA after = (RegionBA) pagemaster.getRegion(Constants.FO_REGION_AFTER);
- attrib.set(RtfPage.PAGE_WIDTH, pagemaster.getPageWidth());
- attrib.set(RtfPage.PAGE_HEIGHT, pagemaster.getPageHeight());
+ attrib.setTwips(RtfPage.PAGE_WIDTH, pagemaster.getPageWidth());
+ attrib.setTwips(RtfPage.PAGE_HEIGHT, pagemaster.getPageHeight());
Length pageTop = pagemaster.getCommonMarginBlock().marginTop;
Length pageBottom = pagemaster.getCommonMarginBlock().marginBottom;
bodyRight = (Length) NumericOp.addition(pageRight, bodyMargin.marginRight);
}
- attrib.set(RtfPage.MARGIN_TOP, bodyTop);
- attrib.set(RtfPage.MARGIN_BOTTOM, bodyBottom);
- attrib.set(RtfPage.MARGIN_LEFT, bodyLeft);
- attrib.set(RtfPage.MARGIN_RIGHT, bodyRight);
+ attrib.setTwips(RtfPage.MARGIN_TOP, bodyTop);
+ attrib.setTwips(RtfPage.MARGIN_BOTTOM, bodyBottom);
+ attrib.setTwips(RtfPage.MARGIN_LEFT, bodyLeft);
+ attrib.setTwips(RtfPage.MARGIN_RIGHT, bodyRight);
//region-before attributes
Length beforeTop = pageTop;
if (before != null) {
beforeTop = (Length) NumericOp.addition(pageTop, before.getExtent());
}
- attrib.set(RtfPage.HEADERY, beforeTop);
+ attrib.setTwips(RtfPage.HEADERY, beforeTop);
//region-after attributes
Length afterBottom = pageBottom;
if (after != null) {
afterBottom = (Length) NumericOp.addition(pageBottom, after.getExtent());
}
- attrib.set(RtfPage.FOOTERY, beforeTop);
+ attrib.setTwips(RtfPage.FOOTERY, beforeTop);
} catch (Exception e) {
log.error("Exception in convertPageAttributes: "
+ e.getMessage() + "- page attributes ignored");
static RtfAttributes convertTableAttributes(Table fobj)
throws FOPException {
FOPRtfAttributes attrib = new FOPRtfAttributes();
- attrib.set(ITableAttributes.ATTR_ROW_LEFT_INDENT, fobj.getCommonMarginBlock().marginLeft);
+ attrib.setTwips(ITableAttributes.ATTR_ROW_LEFT_INDENT, fobj.getCommonMarginBlock().marginLeft);
return attrib;
}
private static void attrFont(CommonFont font, FOPRtfAttributes rtfAttr) {
rtfAttr.set(RtfText.ATTR_FONT_FAMILY,
RtfFontManager.getInstance().getFontNumber(font.fontFamily));
- rtfAttr.set(RtfText.ATTR_FONT_SIZE, font.fontSize);
+ rtfAttr.setHalfPoints(RtfText.ATTR_FONT_SIZE, font.fontSize);
if (font.fontWeight.equals("bold") || font.fontWeight.equals("700")) {
rtfAttr.set("b", 1);
}
private static void attrBlockMargin(CommonMarginBlock cmb, FOPRtfAttributes rtfAttr) {
- rtfAttr.set(RtfText.SPACE_BEFORE,
+ rtfAttr.setTwips(RtfText.SPACE_BEFORE,
cmb.spaceBefore.getOptimum().getLength());
- rtfAttr.set(RtfText.SPACE_AFTER,
+ rtfAttr.setTwips(RtfText.SPACE_AFTER,
cmb.spaceAfter.getOptimum().getLength());
- rtfAttr.set(RtfText.LEFT_INDENT_BODY, cmb.marginLeft);
- rtfAttr.set(RtfText.RIGHT_INDENT_BODY, cmb.marginRight);
+ rtfAttr.setTwips(RtfText.LEFT_INDENT_BODY, cmb.marginLeft);
+ rtfAttr.setTwips(RtfText.RIGHT_INDENT_BODY, cmb.marginRight);
}