/**
* Formatting properties for this fo element.
*/
- public PropertyList propertyList;
+ protected PropertyList propertyList;
/**
* Property manager for handling some common properties.
* @return the property
*/
public Property getProperty(int propId) {
- return (propertyList.get(propId));
+ return propertyList.get(propId);
}
+ /**
+ * Return the "nearest" specified value for the given property.
+ * Implements the from-nearest-specified-value function.
+ * @param propertyName The name of the property whose value is desired.
+ * @return The computed value if the property is explicitly set on some
+ * ancestor of the current FO, else the initial value.
+ */
+ public Property getNearestSpecifiedProperty(int propId) {
+ return propertyList.getNearestSpecified(propId);
+ }
+
+ /**
+ * Return the value explicitly specified on this FO.
+ * @param propertyName The name of the property whose value is desired.
+ * It may be a compound name, such as space-before.optimum.
+ * @return The value if the property is explicitly set, otherwise null.
+ */
+ public Property getExplicitProperty(int propId) {
+ return propertyList.getExplicit(propId);
+ }
+
+ /**
+ * Uses the stored writingMode.
+ * @param absdir an absolute direction (top, bottom, left, right)
+ * @return the corresponding writing model relative direction name
+ * for the flow object.
+ */
+ public int getWritingMode(int lrtb, int rltb, int tbrl) {
+ return propertyList.getWritingMode(lrtb, rltb, tbrl);
+ }
+
+
+ /**
+ * Uses the stored writingMode.
+ * @param relativeWritingMode relative direction (start, end, before, after)
+ * @return the corresponding absolute direction name for the flow object.
+ */
+ public String getAbsoluteWritingMode(int relativeWritingMode) {
+ return propertyList.getAbsoluteWritingMode(relativeWritingMode);
+ }
+
/**
* Setup the id for this formatting object.
* Most formatting objects can have an id that can be referenced.
public class PropertyList extends HashMap {
// writing-mode values
- private byte[] wmtable = null;
+ private byte[] writingModeTable = null;
+
// writing-mode index
private int writingMode;
+
private static boolean[] inheritableProperty;
// absolute directions and dimensions
/** constant for dimension "inline-progression-dimension" */
public static final int INLINEPROGDIM = 5;
- private static final String[] ABS_NAMES = new String[] {
+ private static final String[] ABS_WM_NAMES = new String[] {
"left", "right", "top", "bottom", "height", "width"
};
- private static final String[] REL_NAMES = new String[] {
+ private static final String[] REL_WM_NAMES = new String[] {
"start", "end", "before", "after", "block-progression-dimension",
"inline-progression-dimension"
};
return null; // Exception in makeProperty!
}
+ /**
+ * Set the writing mode traits for the FO with this property list.
+ * @param writingMode the writing-mode property to be set for this object
+ */
+ public void setWritingMode(int writingMode) {
+ this.writingMode = writingMode;
+ this.writingModeTable = (byte[])WRITING_MODE_TABLES.get(new Integer(writingMode));
+ }
+
/**
* Uses the stored writingMode.
* @param absdir an absolute direction (top, bottom, left, right)
* @return the corresponding writing model relative direction name
* for the flow object.
*/
- public int wmMap(int lrtb, int rltb, int tbrl) {
+ public int getWritingMode(int lrtb, int rltb, int tbrl) {
switch (writingMode) {
- case Constants.WritingMode.LR_TB: return lrtb;
- case Constants.WritingMode.RL_TB: return rltb;
- case Constants.WritingMode.TB_RL: return tbrl;
+ case Constants.WritingMode.LR_TB: return lrtb;
+ case Constants.WritingMode.RL_TB: return rltb;
+ case Constants.WritingMode.TB_RL: return tbrl;
}
return -1;
}
/**
* Uses the stored writingMode.
- * @param reldir a writing mode relative direction (start, end, before, after)
+ * @param relativeWritingMode relative direction (start, end, before, after)
* @return the corresponding absolute direction name for the flow object.
*/
- public String wmRelToAbs(int reldir) {
- if (wmtable != null) {
- for (int i = 0; i < wmtable.length; i++) {
- if (wmtable[i] == reldir) {
- return ABS_NAMES[i];
+ public String getAbsoluteWritingMode(int relativeWritingMode) {
+ if (writingModeTable != null) {
+ for (int i = 0; i < writingModeTable.length; i++) {
+ if (writingModeTable[i] == relativeWritingMode) {
+ return ABS_WM_NAMES[i];
}
}
}
return "";
}
- /**
- * Set the writing mode traits for the FO with this property list.
- * @param writingMode the writing-mode property to be set for this object
- */
- public void setWritingMode(int writingMode) {
- this.writingMode = writingMode;
- this.wmtable = (byte[])WRITING_MODE_TABLES.get(new Integer(writingMode));
- }
-
/**
*
* @param attributes Collection of attributes passed to us from the parser.
}
Numeric startIndent =
- ((ListItem)item).propertyList.get(Constants.PR_START_INDENT).getNumeric();
+ ((ListItem)item).getProperty(Constants.PR_START_INDENT).getNumeric();
return (Property) NumericOp.addition(distance, startIndent);
}
if (item == null) {
throw new PropertyException("label-end() called from outside an fo:list-item");
}
- Length startIndent = ((ListItem)item).propertyList.get(Constants.PR_START_INDENT).getLength();
+ Length startIndent = ((ListItem)item).getProperty(Constants.PR_START_INDENT).getLength();
// Should be CONTAINING_REFAREA but that doesn't work
LengthBase base = new LengthBase((ListItem)item, pInfo.getPropertyList(),
private int getRelMargin(int reldir, int relPropId) {
FObj parent = (FObj) getParent();
String sPropName = "margin-"
- + parent.propertyList.wmRelToAbs(reldir);
+ + parent.getAbsoluteWritingMode(reldir);
int propId = FOPropertyMapping.getPropertyId(sPropName);
Property prop = propertyList.getExplicitOrShorthand(propId);
if (prop == null) {
* direction has been specified in the input properties
*/
public boolean isCorrespondingForced(PropertyList propertyList) {
+
if (!relative) {
return false;
}
- PropertyList pList;
- if (useParent) {
- pList = propertyList.getParentFObj().propertyList;
+
+ PropertyList pList = (useParent) ? propertyList.getParentPropertyList() :
+ propertyList;
+
+ int correspondingId = pList.getWritingMode(lr_tb, rl_tb, tb_rl);
+
+ if (pList.getExplicit(correspondingId) != null) {
+ return true;
} else {
- pList = propertyList;
+ return false;
}
- int correspondingId = pList.wmMap(lr_tb, rl_tb, tb_rl);
- if (propertyList.getExplicit(correspondingId) != null)
- return true;
- return false;
}
/**
} else {
pList = propertyList;
}
- int correspondingId = pList.wmMap(lr_tb, rl_tb, tb_rl);
+ int correspondingId = pList.getWritingMode(lr_tb, rl_tb, tb_rl);
Property p = propertyList.getExplicitOrShorthand(correspondingId);
if (p != null) {
}
// Based on min-[width|height]
- int wmcorr = propertyList.wmMap(extraCorresponding[0][0],
+ int wmcorr = propertyList.getWritingMode(extraCorresponding[0][0],
extraCorresponding[0][1],
extraCorresponding[0][2]);
Property subprop = propertyList.getExplicitOrShorthand(wmcorr);
}
// Based on max-[width|height]
- wmcorr = propertyList.wmMap(extraCorresponding[1][0],
+ wmcorr = propertyList.getWritingMode(extraCorresponding[1][0],
extraCorresponding[1][1],
extraCorresponding[1][2]);
subprop = propertyList.getExplicitOrShorthand(wmcorr);
*/
public Property compute(PropertyList propertyList) throws FOPException {
// TODO: bckfnn reenable
- if (propertyList.getExplicitOrShorthand(propertyList.wmMap(lr_tb, rl_tb, tb_rl)) == null) {
+ if (propertyList.getExplicitOrShorthand(
+ propertyList.getWritingMode(lr_tb, rl_tb, tb_rl)) == null) {
return null;
}
// Calculate the values as described in 5.3.2.
v = v.add(propertyList.getInherited(propName).getNumeric());
}
*/
- v = NumericOp.addition(v, propertyList.get(propertyList.wmMap(lr_tb, rl_tb, tb_rl)).getNumeric());
+ v = NumericOp.addition(v, propertyList.get(propertyList.getWritingMode(lr_tb, rl_tb, tb_rl)).getNumeric());
v = NumericOp.addition(v, getCorresponding(paddingCorresponding, propertyList).getNumeric());
v = NumericOp.addition(v, getCorresponding(borderWidthCorresponding, propertyList).getNumeric());
return (Property) v;
}
private Property getCorresponding(int[] corresponding, PropertyList propertyList) {
- int wmcorr = propertyList.wmMap(corresponding[0], corresponding[1], corresponding[2]);
+ int wmcorr = propertyList.getWritingMode(corresponding[0], corresponding[1], corresponding[2]);
return propertyList.get(wmcorr);
}
}
}
}*/
};
- lm.setAlignment(node.propertyList.get(Constants.PR_LEADER_ALIGNMENT).getEnum());
+ lm.setAlignment(node.getProperty(Constants.PR_LEADER_ALIGNMENT).getEnum());
currentLMList.add(lm);
}
}
public InlineArea getCharacterInlineArea(Character node) {
- String str = node.propertyList.get(Constants.PR_CHARACTER).getString();
+ String str = node.getProperty(Constants.PR_CHARACTER).getString();
if (str.length() == 1) {
org.apache.fop.area.inline.Character ch =
new org.apache.fop.area.inline.Character(
node.setupID();
LeafNodeLayoutManager lm = new LeafNodeLayoutManager(node);
lm.setCurrentArea(area);
- lm.setAlignment(node.propertyList.get(Constants.PR_VERTICAL_ALIGN).getEnum());
+ lm.setAlignment(node.getProperty(Constants.PR_VERTICAL_ALIGN).getEnum());
lm.setLead(node.getViewHeight());
currentLMList.add(lm);
}
public void serveBlockContainer(BlockContainer node) {
BlockContainerLayoutManager blm = new BlockContainerLayoutManager(node);
- blm.setOverflow(node.propertyList.get(Constants.PR_OVERFLOW).getEnum());
+ blm.setOverflow(node.getProperty(Constants.PR_OVERFLOW).getEnum());
currentLMList.add(blm);
}
if (areaCurrent != null) {
LeafNodeLayoutManager lm = new LeafNodeLayoutManager(node);
lm.setCurrentArea(areaCurrent);
- lm.setAlignment(node.propertyList.get(Constants.PR_VERTICAL_ALIGN).getEnum());
+ lm.setAlignment(node.getProperty(Constants.PR_VERTICAL_ALIGN).getEnum());
lm.setLead(areaCurrent.getHeight());
currentLMList.add(lm);
}
int ipd = -1;
boolean bpdauto = false;
if (hasLH) {
- bpd = node.propertyList.get(Constants.PR_LINE_HEIGHT).getLength().getValue();
+ bpd = node.getProperty(Constants.PR_LINE_HEIGHT).getLength().getValue();
} else {
// this property does not apply when the line-height applies
// isn't the block-progression-dimension always in the same
// direction as the line height?
- len = node.propertyList.get(Constants.PR_BLOCK_PROGRESSION_DIMENSION | Constants.CP_OPTIMUM).getLength();
+ len = node.getProperty(Constants.PR_BLOCK_PROGRESSION_DIMENSION | Constants.CP_OPTIMUM).getLength();
if (!len.isAuto()) {
bpd = len.getValue();
} else {
- len = node.propertyList.get(Constants.PR_HEIGHT).getLength();
+ len = node.getProperty(Constants.PR_HEIGHT).getLength();
if (!len.isAuto()) {
bpd = len.getValue();
}
}
}
- len = node.propertyList.get(Constants.PR_INLINE_PROGRESSION_DIMENSION | Constants.CP_OPTIMUM).getLength();
+ len = node.getProperty(Constants.PR_INLINE_PROGRESSION_DIMENSION | Constants.CP_OPTIMUM).getLength();
if (!len.isAuto()) {
ipd = len.getValue();
} else {
- len = node.propertyList.get(Constants.PR_WIDTH).getLength();
+ len = node.getProperty(Constants.PR_WIDTH).getLength();
if (!len.isAuto()) {
ipd = len.getValue();
}
// to the content-height and content-width
int cwidth = -1;
int cheight = -1;
- len = node.propertyList.get(Constants.PR_CONTENT_WIDTH).getLength();
+ len = node.getProperty(Constants.PR_CONTENT_WIDTH).getLength();
if (!len.isAuto()) {
/*if(len.scaleToFit()) {
if(ipd != -1) {
} else {*/
cwidth = len.getValue();
}
- len = node.propertyList.get(Constants.PR_CONTENT_HEIGHT).getLength();
+ len = node.getProperty(Constants.PR_CONTENT_HEIGHT).getLength();
if (!len.isAuto()) {
/*if(len.scaleToFit()) {
if(bpd != -1) {
if (cheight == -1) {
cheight = (int)size.getY() * 1000;
}
- int scaling = node.propertyList.get(Constants.PR_SCALING).getEnum();
+ int scaling = node.getProperty(Constants.PR_SCALING).getEnum();
if (scaling == Constants.Scaling.UNIFORM) {
// adjust the larger
double rat1 = cwidth / (size.getX() * 1000f);
boolean clip = false;
if (cwidth > ipd || cheight > bpd) {
- int overflow = node.propertyList.get(Constants.PR_OVERFLOW).getEnum();
+ int overflow = node.getProperty(Constants.PR_OVERFLOW).getEnum();
if (overflow == Constants.Overflow.HIDDEN) {
clip = true;
} else if (overflow == Constants.Overflow.ERROR_IF_OVERFLOW) {
private PageViewport createPageAreas(SimplePageMaster spm) {
int pageWidth =
- spm.propertyList.get(PR_PAGE_WIDTH).getLength().getValue();
+ spm.getProperty(PR_PAGE_WIDTH).getLength().getValue();
int pageHeight =
- spm.propertyList.get(PR_PAGE_HEIGHT).getLength().getValue();
+ spm.getProperty(PR_PAGE_HEIGHT).getLength().getValue();
// Set the page dimension as the toplevel containing block for margin.
((FObj) fobj.getParent()).setLayoutDimension(PercentBase.BLOCK_IPD, pageWidth);
((FObj) fobj.getParent()).setLayoutDimension(PercentBase.BLOCK_BPD, pageHeight);
BodyRegion body = new BodyRegion();
setRegionPosition(r, body, absRegVPRect);
int columnCount =
- r.propertyList.get(PR_COLUMN_COUNT).getNumber().intValue();
+ r.getProperty(PR_COLUMN_COUNT).getNumber().intValue();
if ((columnCount > 1) && (r.overflow == Overflow.SCROLL)) {
// recover by setting 'column-count' to 1. This is allowed but
// not required by the spec.
body.setColumnCount(columnCount);
int columnGap =
- r.propertyList.get(PR_COLUMN_GAP).getLength().getValue();
+ r.getProperty(PR_COLUMN_GAP).getLength().getValue();
body.setColumnGap(columnGap);
return body;
}
* for the JFOR project and is now integrated into FOP.
*/
-
class BuilderContext {
/** stack of RtfContainers */
private final Stack containers = new Stack();
//FOP
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.FObj;
import org.apache.fop.fo.properties.LengthProperty;
import org.apache.fop.fo.properties.Property;
public class ListAttributesConverter {
- static RtfAttributes convertAttributes(PropertyList propertyList)
+ static RtfAttributes convertAttributes(FObj fobj)
throws FOPException {
RtfAttributes attrib = new RtfAttributes();
int iStartIndentInTwips = 0;
//start-indent
- if ((prop = propertyList.get(Constants.PR_START_INDENT)) != null) {
+ if ((prop = fobj.getProperty(Constants.PR_START_INDENT)) != null) {
LengthProperty lengthprop = (LengthProperty)prop;
Float f = new Float(lengthprop.getLength().getValue() / 1000f);
attrib.set(RtfListTable.LIST_INDENT, iStartIndentInTwips);
//end-indent
- if ((prop = propertyList.get(Constants.PR_END_INDENT)) != null) {
+ if ((prop = fobj.getProperty(Constants.PR_END_INDENT)) != null) {
LengthProperty lengthprop = (LengthProperty)prop;
Float f = new Float(lengthprop.getLength().getValue() / 1000f);
import org.apache.fop.fo.pagination.Region;
import org.apache.fop.fo.pagination.SimplePageMaster;
import org.apache.fop.fo.properties.Property;
-import org.apache.fop.fo.PropertyList;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfPage;
float fPageTop = 0;
float fPageBottom = 0;
- PropertyList props = null;
Property p = null;
Float f = null;
Region body = pagemaster.getRegion(Region.BODY_CODE);
Region after = pagemaster.getRegion(Region.AFTER_CODE);
- //page attributes
- props = pagemaster.propertyList;
-
- if ((p = props.get(Constants.PR_PAGE_WIDTH)) != null) {
+ if ((p = pagemaster.getProperty(Constants.PR_PAGE_WIDTH)) != null) {
f = new Float(p.getLength().getValue() / 1000f);
attrib.set(RtfPage.PAGE_WIDTH,
(int)converter.convertToTwips(f.toString() + "pt"));
}
- if ((p = props.get(Constants.PR_PAGE_HEIGHT)) != null) {
+ if ((p = pagemaster.getProperty(Constants.PR_PAGE_HEIGHT)) != null) {
f = new Float(p.getLength().getValue() / 1000f);
attrib.set(RtfPage.PAGE_HEIGHT,
(int)converter.convertToTwips(f.toString() + "pt"));
}
- if ((p = props.get(Constants.PR_MARGIN_TOP)) != null) {
+ if ((p = pagemaster.getProperty(Constants.PR_MARGIN_TOP)) != null) {
fPageTop = p.getLength().getValue() / 1000f;
}
- if ((p = props.get(Constants.PR_MARGIN_BOTTOM)) != null) {
+ if ((p = pagemaster.getProperty(Constants.PR_MARGIN_BOTTOM)) != null) {
fPageBottom = p.getLength().getValue() / 1000f;
}
- if ((p = props.get(Constants.PR_MARGIN_LEFT)) != null) {
+ if ((p = pagemaster.getProperty(Constants.PR_MARGIN_LEFT)) != null) {
f = new Float(p.getLength().getValue() / 1000f);
attrib.set(RtfPage.MARGIN_LEFT,
(int)converter.convertToTwips(f.toString() + "pt"));
}
- if ((p = props.get(Constants.PR_MARGIN_RIGHT)) != null) {
+ if ((p = pagemaster.getProperty(Constants.PR_MARGIN_RIGHT)) != null) {
f = new Float(p.getLength().getValue() / 1000f);
attrib.set(RtfPage.MARGIN_RIGHT,
(int)converter.convertToTwips(f.toString() + "pt"));
float fBodyBottom = fPageBottom;
if (body != null) {
- props = body.propertyList;
-
- if ((p = props.get(Constants.PR_MARGIN_TOP)) != null) {
+ if ((p = body.getProperty(Constants.PR_MARGIN_TOP)) != null) {
fBodyTop += p.getLength().getValue() / 1000f;
}
- if ((p = props.get(Constants.PR_MARGIN_BOTTOM)) != null) {
+ if ((p = body.getProperty(Constants.PR_MARGIN_BOTTOM)) != null) {
fBodyBottom += p.getLength().getValue() / 1000f;
}
}
float fBeforeTop = fPageTop;
if (before != null) {
- props = before.propertyList;
-
- if ((p = props.get(Constants.PR_MARGIN_TOP)) != null) {
+ if ((p = before.getProperty(Constants.PR_MARGIN_TOP)) != null) {
fBeforeTop += p.getLength().getValue() / 1000f;
}
}
float fAfterBottom = fPageBottom;
if (after != null) {
- props = after.propertyList;
-
- if ((p = props.get(Constants.PR_MARGIN_BOTTOM)) != null) {
+ if ((p = after.getProperty(Constants.PR_MARGIN_BOTTOM)) != null) {
fAfterBottom += p.getLength().getValue() / 1000f;
}
}
//read page size and margins, if specified
Property prop;
- if ((prop = pageSeq.propertyList.get(Constants.PR_MASTER_REFERENCE)) != null) {
+ if ((prop = pageSeq.getProperty(Constants.PR_MASTER_REFERENCE)) != null) {
String reference = prop.getString();
SimplePageMaster pagemaster
try {
RtfAttributes rtfAttr
- = TextAttributesConverter.convertAttributes(bl.propertyList, null);
+ = TextAttributesConverter.convertAttributes(bl);
IRtfTextrunContainer container
= (IRtfTextrunContainer)builderContext.getContainer(
try {
RtfAttributes atts
- = TableAttributesConverter.convertTableAttributes(tbl.propertyList);
+ = TableAttributesConverter.convertTableAttributes(tbl);
final IRtfTableContainer tc
= (IRtfTableContainer)builderContext.getContainer(
try {
RtfAttributes rtfAttr
- = TextAttributesConverter.convertCharacterAttributes(inl.propertyList, null);
+ = TextAttributesConverter.convertCharacterAttributes(inl);
IRtfTextrunContainer container
= (IRtfTextrunContainer)builderContext.getContainer(
}
try {
- RtfAttributes atts = TableAttributesConverter.convertRowAttributes (tb.propertyList,
+ RtfAttributes atts = TableAttributesConverter.convertRowAttributes (tb,
null);
RtfTable tbl = (RtfTable)builderContext.getContainer(RtfTable.class, true, this);
final RtfTable tbl = (RtfTable)builderContext.getContainer(RtfTable.class,
true, null);
- RtfAttributes atts = TableAttributesConverter.convertRowAttributes(tr.propertyList,
+ RtfAttributes atts = TableAttributesConverter.convertRowAttributes(tr,
tbl.getHeaderAttribs());
if (tr.getParent() instanceof TableHeader) {
float width = tctx.getColumnWidth();
// create an RtfTableCell in the current RtfTableRow
- RtfAttributes atts = TableAttributesConverter.convertCellAttributes(tc.propertyList);
+ RtfAttributes atts = TableAttributesConverter.convertCellAttributes(tc);
RtfTableCell cell = row.newTableCell((int)width, atts);
//process number-rows-spanned attribute
Property p = null;
- if ((p = tc.propertyList.get(Constants.PR_NUMBER_ROWS_SPANNED)) != null) {
+ if ((p = tc.getProperty(Constants.PR_NUMBER_ROWS_SPANNED)) != null) {
// Start vertical merge
cell.setVMerge(RtfTableCell.MERGE_START);
= (IRtfListContainer)builderContext.getContainer(
IRtfListContainer.class, true, this);
final RtfList newList = c.newList(
- ListAttributesConverter.convertAttributes(lb.propertyList));
+ ListAttributesConverter.convertAttributes(lb));
builderContext.pushContainer(newList);
} catch (IOException ioe) {
log.error("startList: " + ioe.getMessage());
RtfHyperLink link=textrun.addHyperlink(new RtfAttributes());
StringProperty internal
- = (StringProperty)basicLink.propertyList.get(Constants.PR_INTERNAL_DESTINATION);
+ = (StringProperty)basicLink.getProperty(Constants.PR_INTERNAL_DESTINATION);
StringProperty external
- = (StringProperty)basicLink.propertyList.get(Constants.PR_EXTERNAL_DESTINATION);
+ = (StringProperty)basicLink.getProperty(Constants.PR_EXTERNAL_DESTINATION);
if(external != null) {
link.setExternalURL(external.getString());
Property p = null;
//get source file
- if ((p = eg.propertyList.get(Constants.PR_SRC)) != null) {
+ if ((p = eg.getProperty(Constants.PR_SRC)) != null) {
newGraphic.setURL (p.getString());
} else {
log.error("The attribute 'src' of <fo:external-graphic> is required.");
}
//get scaling
- if ((p = eg.propertyList.get(Constants.PR_SCALING)) != null) {
+ if ((p = eg.getProperty(Constants.PR_SCALING)) != null) {
EnumProperty e = (EnumProperty)p;
if (p.getEnum() == Constants.UNIFORM) {
newGraphic.setScaling ("uniform");
}
//get width
- if ((p = eg.propertyList.get(Constants.PR_WIDTH)) != null) {
+ if ((p = eg.getProperty(Constants.PR_WIDTH)) != null) {
LengthProperty lengthProp = (LengthProperty)p;
if (lengthProp.getLength() instanceof FixedLength) {
Float f = new Float(lengthProp.getLength().getValue() / 1000f);
}
//get height
- if ((p = eg.propertyList.get(Constants.PR_HEIGHT)) != null) {
+ if ((p = eg.getProperty(Constants.PR_HEIGHT)) != null) {
LengthProperty lengthProp = (LengthProperty)p;
if (lengthProp.getLength() instanceof FixedLength) {
Float f = new Float(lengthProp.getLength().getValue() / 1000f);
try {
RtfAttributes rtfAttr
- = TextAttributesConverter.convertAttributes(footnote.propertyList, null);
+ = TextAttributesConverter.convertAttributes(footnote);
IRtfTextrunContainer container
= (IRtfTextrunContainer)builderContext.getContainer(
try {
RtfAttributes rtfAttr
= TextAttributesConverter.convertCharacterAttributes(
- pagenum.propertyList, null);
+ pagenum);
IRtfTextrunContainer container
= (IRtfTextrunContainer)builderContext.getContainer(
import org.apache.fop.fo.properties.NumberProperty;
import org.apache.fop.fo.properties.Property;
import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.FObj;
import org.apache.fop.datatypes.ColorType;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
*
* @throws ConverterException On convertion error
*/
- static RtfAttributes convertTableAttributes(PropertyList propertyList)
+ static RtfAttributes convertTableAttributes(FObj fobj)
throws FOPException {
RtfAttributes attrib = new RtfAttributes();
LengthProperty lengthProp = null;
// margin-left
- lengthProp = (LengthProperty)propertyList.get(Constants.PR_MARGIN_LEFT);
+ lengthProp = (LengthProperty)fobj.getProperty(Constants.PR_MARGIN_LEFT);
if (lengthProp != null) {
Float f = new Float(lengthProp.getLength().getValue() / 1000f);
final String sValue = f.toString() + "pt";
/**
* Converts cell attributes to rtf attributes.
- * @param attrs Given attributes
- * @param defaultAttributes Default rtf attributes
+ * @param fobj FObj whose properties are to be converted
*
* @return All valid rtf attributes together
*
- * @throws ConverterException On convertion error
+ * @throws ConverterException On conversion error
*/
- static RtfAttributes convertCellAttributes(PropertyList props)
+ static RtfAttributes convertCellAttributes(FObj fobj)
throws FOPException {
Property p;
RtfAttributes attrib = null;
- attrib = new RtfAttributes();
+ attrib = new RtfAttributes();
boolean isBorderPresent = false;
// Cell background color
- if ((p = props.getNearestSpecified(Constants.PR_BACKGROUND_COLOR)) != null) {
+ if ((p = fobj.getNearestSpecifiedProperty(Constants.PR_BACKGROUND_COLOR)) != null) {
ColorType color = p.getColorType();
if (color != null) {
if (color.getAlpha() != 0
}
// Cell borders :
- if ((p = props.getExplicit(Constants.PR_BORDER_COLOR)) != null) {
+ if ((p = fobj.getExplicitProperty(Constants.PR_BORDER_COLOR)) != null) {
ListProperty listprop = (ListProperty) p;
ColorType color = null;
if (listprop.getList().get(0) instanceof NCnameProperty) {
colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(),
(int)color.getBlue()).intValue());
}
- if ((p = props.getExplicit(Constants.PR_BORDER_TOP_COLOR)) != null) {
+ if ((p = fobj.getExplicitProperty(Constants.PR_BORDER_TOP_COLOR)) != null) {
ColorType color = p.getColorType();
attrib.set(
BorderAttributesConverter.BORDER_COLOR,
colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(),
(int)color.getBlue()).intValue());
}
- if ((p = props.getExplicit(Constants.PR_BORDER_BOTTOM_COLOR)) != null) {
+ if ((p = fobj.getExplicitProperty(Constants.PR_BORDER_BOTTOM_COLOR)) != null) {
ColorType color = p.getColorType();
attrib.set(
BorderAttributesConverter.BORDER_COLOR,
colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(),
(int)color.getBlue()).intValue());
}
- if ((p = props.getExplicit(Constants.PR_BORDER_LEFT_COLOR)) != null) {
+ if ((p = fobj.getExplicitProperty(Constants.PR_BORDER_LEFT_COLOR)) != null) {
ColorType color = p.getColorType();
attrib.set(
BorderAttributesConverter.BORDER_COLOR,
colorTable.getColorNumber((int)color.getRed(), (int)color.getGreen(),
(int)color.getBlue()).intValue());
}
- if ((p = props.getExplicit(Constants.PR_BORDER_RIGHT_COLOR)) != null) {
+ if ((p = fobj.getExplicitProperty(Constants.PR_BORDER_RIGHT_COLOR)) != null) {
ColorType color = p.getColorType();
attrib.set(
BorderAttributesConverter.BORDER_COLOR,
// Border styles do not inherit from parent
- ep = (EnumProperty)props.get(Constants.PR_BORDER_TOP_STYLE);
+ ep = (EnumProperty)fobj.getProperty(Constants.PR_BORDER_TOP_STYLE);
if (ep != null && ep.getEnum() != Constants.NONE) {
attrib.set(ITableAttributes.CELL_BORDER_TOP, "\\"
+ convertAttributetoRtf(ep.getEnum()));
isBorderPresent = true;
}
- ep = (EnumProperty)props.get(Constants.PR_BORDER_BOTTOM_STYLE);
+ ep = (EnumProperty)fobj.getProperty(Constants.PR_BORDER_BOTTOM_STYLE);
if (ep != null && ep.getEnum() != Constants.NONE) {
attrib.set(ITableAttributes.CELL_BORDER_BOTTOM, "\\"
+ convertAttributetoRtf(ep.getEnum()));
isBorderPresent = true;
}
- ep = (EnumProperty)props.get(Constants.PR_BORDER_LEFT_STYLE);
+ ep = (EnumProperty)fobj.getProperty(Constants.PR_BORDER_LEFT_STYLE);
if (ep != null && ep.getEnum() != Constants.NONE) {
attrib.set(ITableAttributes.CELL_BORDER_LEFT, "\\"
+ convertAttributetoRtf(ep.getEnum()));
isBorderPresent = true;
}
- ep = (EnumProperty)props.get(Constants.PR_BORDER_RIGHT_STYLE);
+ ep = (EnumProperty)fobj.getProperty(Constants.PR_BORDER_RIGHT_STYLE);
if (ep != null && ep.getEnum() != Constants.NONE) {
attrib.set(ITableAttributes.CELL_BORDER_RIGHT, "\\"
+ convertAttributetoRtf(ep.getEnum()));
}
//Currently there is only one border width supported in each cell.
- p = props.get(Constants.PR_BORDER_LEFT_WIDTH);
+ p = fobj.getProperty(Constants.PR_BORDER_LEFT_WIDTH);
if(p == null) {
- p = props.get(Constants.PR_BORDER_RIGHT_WIDTH);
+ p = fobj.getProperty(Constants.PR_BORDER_RIGHT_WIDTH);
}
if(p == null) {
- p = props.get(Constants.PR_BORDER_TOP_WIDTH);
+ p = fobj.getProperty(Constants.PR_BORDER_TOP_WIDTH);
}
if(p == null) {
- p = props.get(Constants.PR_BORDER_BOTTOM_WIDTH);
+ p = fobj.getProperty(Constants.PR_BORDER_BOTTOM_WIDTH);
}
if (p != null) {
LengthProperty lengthprop = (LengthProperty)p;
// Column spanning :
- NumberProperty n = (NumberProperty)props.get(Constants.PR_NUMBER_COLUMNS_SPANNED);
+ NumberProperty n = (NumberProperty)fobj.getProperty(Constants.PR_NUMBER_COLUMNS_SPANNED);
if (n != null && n.getNumber().intValue() > 1) {
attrib.set(ITableAttributes.COLUMN_SPAN, n.getNumber().intValue());
}
/**
* Converts table and row attributes to rtf attributes.
*
- * @param attrs Given attributes
+ * @param fobj FObj to be converted
* @param defaultAttributes Default rtf attributes
*
* @return All valid rtf attributes together
- *
- * @throws ConverterException On convertion error
+ * @throws ConverterException On converion error
*/
- static RtfAttributes convertRowAttributes(PropertyList props,
+ static RtfAttributes convertRowAttributes(FObj fobj,
RtfAttributes rtfatts)
throws FOPException {
//need to set a default width
//check for keep-together row attribute
- if ((p = props.get(Constants.PR_KEEP_TOGETHER | Constants.CP_WITHIN_PAGE)) != null) {
+ if ((p = fobj.getProperty(Constants.PR_KEEP_TOGETHER | Constants.CP_WITHIN_PAGE)) != null) {
attrib.set(ITableAttributes.ROW_KEEP_TOGETHER);
}
- if ((p = props.get(Constants.PR_KEEP_TOGETHER)) != null) {
+ if ((p = fobj.getProperty(Constants.PR_KEEP_TOGETHER)) != null) {
attrib.set(ITableAttributes.ROW_KEEP_TOGETHER);
}
//Check for keep-with-next row attribute.
- if ((p = props.get(Constants.PR_KEEP_WITH_NEXT)) != null) {
+ if ((p = fobj.getProperty(Constants.PR_KEEP_WITH_NEXT)) != null) {
attrib.set(ITableAttributes.ROW_KEEP_WITH_NEXT);
}
//Check for keep-with-previous row attribute.
- if ((p = props.get(Constants.PR_KEEP_WITH_PREVIOUS)) != null) {
+ if ((p = fobj.getProperty(Constants.PR_KEEP_WITH_PREVIOUS)) != null) {
attrib.set(ITableAttributes.ROW_KEEP_WITH_PREVIOUS);
}
//Check for height row attribute.
- if ((p = props.get(Constants.PR_HEIGHT)) != null) {
+ if ((p = fobj.getProperty(Constants.PR_HEIGHT)) != null) {
Float f = new Float(p.getLength().getValue() / 1000);
attrValue = f.toString() + "pt";
attrib.set(ITableAttributes.ROW_HEIGHT,
* place.
*/
- ep = (EnumProperty)props.get(Constants.PR_BORDER_TOP_STYLE);
+ ep = (EnumProperty)fobj.getProperty(Constants.PR_BORDER_TOP_STYLE);
if (ep != null && ep.getEnum() != Constants.NONE) {
attrib.set(ITableAttributes.ROW_BORDER_TOP, "\\"
+ convertAttributetoRtf(ep.getEnum()));
+ convertAttributetoRtf(ep.getEnum()));
isBorderPresent = true;
}
- ep = (EnumProperty)props.get(Constants.PR_BORDER_BOTTOM_STYLE);
+ ep = (EnumProperty)fobj.getProperty(Constants.PR_BORDER_BOTTOM_STYLE);
if (ep != null && ep.getEnum() != Constants.NONE) {
attrib.set(ITableAttributes.ROW_BORDER_BOTTOM, "\\"
+ convertAttributetoRtf(ep.getEnum()));
+ convertAttributetoRtf(ep.getEnum()));
isBorderPresent = true;
}
- ep = (EnumProperty)props.get(Constants.PR_BORDER_LEFT_STYLE);
+ ep = (EnumProperty)fobj.getProperty(Constants.PR_BORDER_LEFT_STYLE);
if (ep != null && ep.getEnum() != Constants.NONE) {
attrib.set(ITableAttributes.ROW_BORDER_LEFT, "\\"
+ convertAttributetoRtf(ep.getEnum()));
+ convertAttributetoRtf(ep.getEnum()));
isBorderPresent = true;
}
- ep = (EnumProperty)props.get(Constants.PR_BORDER_RIGHT_STYLE);
+ ep = (EnumProperty)fobj.getProperty(Constants.PR_BORDER_RIGHT_STYLE);
if (ep != null && ep.getEnum() != Constants.NONE) {
attrib.set(ITableAttributes.ROW_BORDER_RIGHT, "\\"
+ convertAttributetoRtf(ep.getEnum()));
+ convertAttributetoRtf(ep.getEnum()));
isBorderPresent = true;
}
- ep = (EnumProperty)props.get("border-horizontal-style");
- if (ep != null && ep.getEnum() != Constants.NONE) {
- attrib.set(ITableAttributes.ROW_BORDER_HORIZONTAL, "\\"
- + convertAttributetoRtf(ep.getEnum()));
- attrib.set(ITableAttributes.ROW_BORDER_TOP, "\\"
- + convertAttributetoRtf(ep.getEnum()));
- attrib.set(ITableAttributes.ROW_BORDER_BOTTOM, "\\"
- + convertAttributetoRtf(ep.getEnum()));
- isBorderPresent = true;
- }
- ep = (EnumProperty)props.get("border-vertical-style");
- if (ep != null && ep.getEnum() != Constants.NONE) {
- attrib.set(ITableAttributes.ROW_BORDER_VERTICAL, "\\"
- + convertAttributetoRtf(ep.getEnum()));
- attrib.set(ITableAttributes.ROW_BORDER_LEFT, "\\"
- + convertAttributetoRtf(ep.getEnum()));
- attrib.set(ITableAttributes.ROW_BORDER_RIGHT, "\\"
- + convertAttributetoRtf(ep.getEnum()));
- isBorderPresent = true;
- }
//Currently there is only one border width supported in each cell.
- p = props.get(Constants.PR_BORDER_LEFT_WIDTH);
+ p = fobj.getProperty(Constants.PR_BORDER_LEFT_WIDTH);
if(p == null) {
- p = props.get(Constants.PR_BORDER_RIGHT_WIDTH);
+ p = fobj.getProperty(Constants.PR_BORDER_RIGHT_WIDTH);
}
if(p == null) {
- p = props.get(Constants.PR_BORDER_TOP_WIDTH);
+ p = fobj.getProperty(Constants.PR_BORDER_TOP_WIDTH);
}
if(p == null) {
- p = props.get(Constants.PR_BORDER_BOTTOM_WIDTH);
+ p = fobj.getProperty(Constants.PR_BORDER_BOTTOM_WIDTH);
}
if (p != null) {
LengthProperty lengthprop = (LengthProperty)p;
import org.apache.commons.logging.impl.SimpleLog;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.FObj;
import org.apache.fop.fo.properties.ColorTypeProperty;
import org.apache.fop.fo.properties.EnumProperty;
import org.apache.fop.fo.properties.LengthProperty;
/**
* Converts all known text FO properties to RtfAttributes
* @param props list of FO properites, which are to be converted
- * @param props list of default FO properites (usally null)
*/
- public static RtfAttributes convertAttributes(PropertyList props, PropertyList defProps)
+ public static RtfAttributes convertAttributes(FObj fobj)
throws FOPException {
RtfAttributes attrib = null;
- if (defProps != null) {
- attrib = convertAttributes(defProps, null);
- } else {
- attrib = new RtfAttributes();
- }
-
- attrBlockFontFamily(props, attrib);
- attrBlockFontWeight(props, attrib);
- attrBlockFontSize(props, attrib);
- attrBlockFontColor(props, attrib);
- attrBlockFontItalic(props, attrib);
- attrBlockFontUnderline(props, attrib);
- attrBlockBackgroundColor(props, attrib);
- attrBlockSpaceBeforeAfter(props, attrib);
- attrBlockMargins(props, attrib);
- attrBlockTextAlign(props, attrib);
+ attrib = new RtfAttributes();
+ attrBlockFontFamily(fobj, attrib);
+ attrBlockFontWeight(fobj, attrib);
+ attrBlockFontSize(fobj, attrib);
+ attrBlockFontColor(fobj, attrib);
+ attrBlockFontItalic(fobj, attrib);
+ attrBlockFontUnderline(fobj, attrib);
+ attrBlockBackgroundColor(fobj, attrib);
+ attrBlockSpaceBeforeAfter(fobj, attrib);
+ attrBlockMargins(fobj, attrib);
+ attrBlockTextAlign(fobj, attrib);
return attrib;
}
/**
* Converts all character related FO properties to RtfAttributes.
- * @param props list of FO properites, which are to be converted
- * @param props list of default FO properites (usally null)
+ * @param fobj FObj whose properties are to be converted
*/
public static RtfAttributes convertCharacterAttributes(
- PropertyList props, PropertyList defProps) throws FOPException {
-
- RtfAttributes attrib = null;
-
- if (defProps != null) {
- attrib = convertCharacterAttributes(defProps, null);
- } else {
- attrib = new RtfAttributes();
- }
-
- attrBlockFontFamily(props, attrib);
- attrBlockFontWeight(props, attrib);
- attrBlockFontSize(props, attrib);
- attrBlockFontColor(props, attrib);
- attrBlockFontItalic(props, attrib);
- attrBlockFontUnderline(props, attrib);
- attrBlockBackgroundColor(props, attrib);
-
+ FObj fobj) throws FOPException {
+
+ RtfAttributes attrib = new RtfAttributes();
+ attrBlockFontFamily(fobj, attrib);
+ attrBlockFontWeight(fobj, attrib);
+ attrBlockFontSize(fobj, attrib);
+ attrBlockFontColor(fobj, attrib);
+ attrBlockFontItalic(fobj, attrib);
+ attrBlockFontUnderline(fobj, attrib);
+ attrBlockBackgroundColor(fobj, attrib);
return attrib;
}
- private static void attrBlockFontFamily(PropertyList propertyList, RtfAttributes rtfAttr) {
- String fopValue = propertyList.get(Constants.PR_FONT_FAMILY).getString();
+ private static void attrBlockFontFamily(FObj fobj, RtfAttributes rtfAttr) {
+ String fopValue = fobj.getProperty(Constants.PR_FONT_FAMILY).getString();
if (fopValue != null) {
rtfAttr.set(RtfText.ATTR_FONT_FAMILY,
}
}
- private static void attrBlockFontSize(PropertyList propertyList, RtfAttributes rtfAttr) {
- int fopValue = propertyList.get(Constants.PR_FONT_SIZE).getLength().getValue() / 500;
+ private static void attrBlockFontSize(FObj fobj, RtfAttributes rtfAttr) {
+ int fopValue = fobj.getProperty(Constants.PR_FONT_SIZE).getLength().getValue() / 500;
rtfAttr.set("fs", fopValue);
}
- private static void attrBlockFontColor(PropertyList propertyList, RtfAttributes rtfAttr) {
+ private static void attrBlockFontColor(FObj fobj, RtfAttributes rtfAttr) {
// Cell background color
- ColorTypeProperty colorTypeProp = (ColorTypeProperty)propertyList.get(Constants.PR_COLOR);
+ ColorTypeProperty colorTypeProp = (ColorTypeProperty)fobj.getProperty(Constants.PR_COLOR);
if (colorTypeProp != null) {
ColorType colorType = colorTypeProp.getColorType();
if (colorType != null) {
- private static void attrBlockFontWeight(PropertyList propertyList, RtfAttributes rtfAttr) {
- String fopValue = propertyList.get(Constants.PR_FONT_WEIGHT).getString();
+ private static void attrBlockFontWeight(FObj fobj, RtfAttributes rtfAttr) {
+ String fopValue = fobj.getProperty(Constants.PR_FONT_WEIGHT).getString();
if (fopValue == "bold" || fopValue == "700") {
rtfAttr.set("b", 1);
} else {
}
}
- private static void attrBlockFontItalic(PropertyList propertyList, RtfAttributes rtfAttr) {
- String fopValue = propertyList.get(Constants.PR_FONT_STYLE).getString();
+ private static void attrBlockFontItalic(FObj fobj, RtfAttributes rtfAttr) {
+ String fopValue = fobj.getProperty(Constants.PR_FONT_STYLE).getString();
if (fopValue.equals("italic")) {
rtfAttr.set(RtfText.ATTR_ITALIC, 1);
} else {
}
}
- private static void attrBlockFontUnderline(PropertyList propertyList, RtfAttributes rtfAttr) {
- EnumProperty enumProp = (EnumProperty) propertyList.get(Constants.PR_TEXT_DECORATION);
+ private static void attrBlockFontUnderline(FObj fobj, RtfAttributes rtfAttr) {
+ EnumProperty enumProp = (EnumProperty) fobj.getProperty(Constants.PR_TEXT_DECORATION);
if (enumProp.getEnum() == Constants.UNDERLINE) {
rtfAttr.set(RtfText.ATTR_UNDERLINE, 1);
} else {
}
}
- private static void attrBlockSpaceBeforeAfter(PropertyList propertyList, RtfAttributes rtfAttr) {
+ private static void attrBlockSpaceBeforeAfter(FObj fobj, RtfAttributes rtfAttr) {
SpaceProperty spaceProp = null;
//space-before
- spaceProp = (SpaceProperty)propertyList.get(Constants.PR_SPACE_BEFORE);
+ spaceProp = (SpaceProperty)fobj.getProperty(Constants.PR_SPACE_BEFORE);
if (spaceProp != null) {
Float f = new Float(
spaceProp.getLengthRange().getOptimum().getLength().getValue() / 1000f);
}
//space-after
- spaceProp = (SpaceProperty)propertyList.get(Constants.PR_SPACE_AFTER);
+ spaceProp = (SpaceProperty)fobj.getProperty(Constants.PR_SPACE_AFTER);
if (spaceProp != null) {
Float f = new Float(
spaceProp.getLengthRange().getOptimum().getLength().getValue() / 1000f);
}
}
- private static void attrBlockMargins(PropertyList propertyList, RtfAttributes rtfAttr) {
+ private static void attrBlockMargins(FObj fobj, RtfAttributes rtfAttr) {
try {
LengthProperty lengthProp = null;
// margin-left
- lengthProp = (LengthProperty)propertyList.get(Constants.PR_MARGIN_LEFT);
+ lengthProp = (LengthProperty)fobj.getProperty(Constants.PR_MARGIN_LEFT);
if (lengthProp != null) {
Float f = new Float(lengthProp.getLength().getValue() / 1000f);
String sValue = f.toString() + "pt";
}
// margin-right
- lengthProp = (LengthProperty)propertyList.get(Constants.PR_MARGIN_RIGHT);
+ lengthProp = (LengthProperty)fobj.getProperty(Constants.PR_MARGIN_RIGHT);
if (lengthProp != null) {
Float f = new Float(lengthProp.getLength().getValue() / 1000f);
String sValue = f.toString() + "pt";
- private static void attrBlockTextAlign(PropertyList propertyList, RtfAttributes rtfAttr) {
- int fopValue = propertyList.get(Constants.PR_TEXT_ALIGN).getEnum();
+ private static void attrBlockTextAlign(FObj fobj, RtfAttributes rtfAttr) {
+ int fopValue = fobj.getProperty(Constants.PR_TEXT_ALIGN).getEnum();
String rtfValue = null;
switch (fopValue) {
case Constants.CENTER:
* @param bl the Block object the properties are read from
* @param rtfAttr the RtfAttributes object the attributes are written to
*/
- private static void attrBlockBackgroundColor(PropertyList propertyList, RtfAttributes rtfAttr) {
- ColorType fopValue = propertyList.get(Constants.PR_BACKGROUND_COLOR).getColorType();
+ private static void attrBlockBackgroundColor(FObj fobj, RtfAttributes rtfAttr) {
+ ColorType fopValue = fobj.getProperty(Constants.PR_BACKGROUND_COLOR).getColorType();
int rtfColor = 0;
/* FOP uses a default background color of "transparent", which is
actually a transparent black, which is generally not suitable as a