return this;
}
+ /**
+ * Set an attribute using a value in millipoints (internal units in twips)
+ * @param name name of attribute
+ * @param value value of attribute (in millipoints)
+ * @return this (which now contains the new entry)
+ */
+ public RtfAttributes setTwips(String name, int value) {
+ set(name, value / (1000 / 20)); //Convert millipoints to twips
+ return this;
+ }
+
/**
* Set an attribute that has a Length value (internal units in half-points)
* @param name name of attribute
FOPRtfAttributes attrib = new FOPRtfAttributes();
boolean isBorderPresent = false;
+ CommonBorderPaddingBackground border = fobj.getCommonBorderPaddingBackground();
// Cell background color
- ColorType color = fobj.getCommonBorderPaddingBackground().backgroundColor;
+ ColorType color = border.backgroundColor;
if ((color != null)
&& (color.getAlpha() != 0
|| color.getRed() != 0
attrib.set(ITableAttributes.CELL_COLOR_BACKGROUND, color);
}
- CommonBorderPaddingBackground border = fobj.getCommonBorderPaddingBackground();
BorderAttributesConverter.makeBorder(border, CommonBorderPaddingBackground.BEFORE,
attrib, ITableAttributes.CELL_BORDER_TOP);
BorderAttributesConverter.makeBorder(border, CommonBorderPaddingBackground.AFTER,
BorderAttributesConverter.makeBorder(border, CommonBorderPaddingBackground.END,
attrib, ITableAttributes.CELL_BORDER_RIGHT);
+ int padding;
+ boolean reproduceMSWordBug = true;
+ //TODO Make this configurable
+ if (reproduceMSWordBug) {
+ //MS Word has a bug where padding left and top are exchanged
+ padding = border.getPaddingStart(false);
+ if (padding != 0) {
+ attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_TOP, padding);
+ attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_TOP, 3 /*=twips*/);
+ }
+ padding = border.getPaddingBefore(false);
+ if (padding != 0) {
+ attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_LEFT, padding);
+ attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_LEFT, 3 /*=twips*/);
+ }
+ } else {
+ padding = border.getPaddingStart(false);
+ if (padding != 0) {
+ attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_LEFT, padding);
+ attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_LEFT, 3 /*=twips*/);
+ }
+ padding = border.getPaddingBefore(false);
+ if (padding != 0) {
+ attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_TOP, padding);
+ attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_TOP, 3 /*=twips*/);
+ }
+ }
+ padding = border.getPaddingEnd(false);
+ if (padding != 0) {
+ attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_RIGHT, padding);
+ attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_RIGHT, 3 /*=twips*/);
+ }
+ padding = border.getPaddingAfter(false);
+ if (padding != 0) {
+ attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_BOTTOM, padding);
+ attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_BOTTOM, 3 /*=twips*/);
+ }
+
int n = fobj.getNumberColumnsSpanned();
// Column spanning :
if (n > 1) {
return;
}
+ header.newLine();
header.writeGroupMark (true);
//Don't use writeControlWord, because it appends a blank,
//which may confuse Wordpad.
for (int i = 0; i < len; i++) {
int identifier = ((Integer) colorTable.get (i)).intValue ();
+ header.newLine();
header.write ("\\red" + determineColorLevel (identifier, RED));
header.write ("\\green" + determineColorLevel (identifier, GREEN));
header.write ("\\blue" + determineColorLevel (identifier, BLUE) + ";");
}
+ header.newLine();
header.writeGroupMark (false);
}
}
}
+ /**
+ * Starts a new line in the RTF file being written. This is only to format
+ * the RTF file itself (for easier debugging), not its content.
+ * @throws IOException in case of an I/O problem
+ */
+ protected void newLine() throws IOException {
+ writer.write("\n");
+ }
+
/**
* Write an RTF control word to our Writer
* @param word RTF control word to write
return;
}
+ header.newLine();
header.writeGroupMark (true);
header.writeControlWord ("fonttbl;");
for (int i = 0; i < len; i++) {
header.writeGroupMark (true);
+ header.newLine();
header.write ("\\f" + i);
header.write (" " + (String) fontTable.elementAt (i));
header.writeGroupMark (false);
}
+ header.newLine();
header.writeGroupMark (false);
}
* @see org.apache.fop.render.rtf.rtflib.rtfdoc.RtfElement#writeRtfContent()
*/
protected void writeRtfContent() throws IOException {
- parent.writeGroupMark(true);
- parent.writeStarControlWord("generator");
- parent.writer.write("Apache FOP ");
- parent.writer.write(Fop.getVersion());
- parent.writer.write(";");
- parent.writeGroupMark(false);
+ newLine();
+ writeGroupMark(true);
+ writeStarControlWord("generator");
+ writer.write("Apache FOP ");
+ writer.write(Fop.getVersion());
+ writer.write(";");
+ writeGroupMark(false);
}
/**
*write properties for footnote handling
*/
private void writeFootnoteProperties() throws IOException {
- writeControlWord("fet0"); //footnotes, not endnotes
- writeControlWord("ftnbj"); //place footnotes at the end of the
- //page (should be the default, but
- //Word 2000 thinks otherwise)
+ newLine();
+ writeControlWord("fet0"); //footnotes, not endnotes
+ writeControlWord("ftnbj"); //place footnotes at the end of the
+ //page (should be the default, but
+ //Word 2000 thinks otherwise)
}
}
* @return widthOffset + width of this cell
*/
int writeCellDef(int widthOffset) throws IOException {
+ newLine();
this.widthOffset = widthOffset;
// vertical cell merge codes
writeControlWord("cellx" + xPos);
+ //TODO Why is this here, right after an alignment command is written (see above)?
writeControlWord("ql");
return xPos;
* @throws IOException for I/O problems
*/
protected void writeRtfPrefix() throws IOException {
+ newLine();
writeGroupMark(true);
}
index++; // Added by Boris POUDEROUS on 2002/07/02
}
+ newLine();
+
// now children can write themselves, we have the correct RTF prefix code
super.writeRtfContent();
}
if (rtfListItem != null) {
rtfListItem.getRtfListStyle().writeParagraphPrefix(this);
}
-
+
//write all children
boolean bPrevPar = false;
boolean bFirst = true;
&& e == lastParagraphBreak));
if (!bHide) {
+ newLine();
e.writeRtf();
if (rtfListItem != null && e instanceof RtfParagraphBreak) {