import org.apache.fop.fo.flow.TableHeader;
import org.apache.fop.fo.flow.TableRow;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
-import org.apache.fop.fo.properties.Property;
import org.apache.fop.render.rtf.BorderAttributesConverter;
import org.apache.fop.render.rtf.rtflib.rtfdoc.ITableAttributes;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;
-import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfColorTable;
/**
* Contributor(s):
static RtfAttributes convertTableAttributes(Table fobj)
throws FOPException {
FOPRtfAttributes attrib = new FOPRtfAttributes();
- attrib.setTwips(ITableAttributes.ATTR_ROW_LEFT_INDENT, fobj.getCommonMarginBlock().marginLeft);
+ attrib.setTwips(ITableAttributes.ATTR_ROW_LEFT_INDENT,
+ fobj.getCommonMarginBlock().marginLeft);
return attrib;
}
static RtfAttributes convertCellAttributes(TableCell fobj)
throws FOPException {
- Property p;
- RtfColorTable colorTable = RtfColorTable.getInstance();
+ //Property p;
+ //RtfColorTable colorTable = RtfColorTable.getInstance();
FOPRtfAttributes attrib = new FOPRtfAttributes();
- boolean isBorderPresent = false;
+ //boolean isBorderPresent = false;
CommonBorderPaddingBackground border = fobj.getCommonBorderPaddingBackground();
// Cell background color
CommonBorderPaddingBackground brd = null;
if (fobj.getParent() instanceof TableRow) {
- TableRow parentRow=(TableRow)fobj.getParent();
+ TableRow parentRow = (TableRow)fobj.getParent();
brd = parentRow.getCommonBorderPaddingBackground();
color = brd.backgroundColor;
} else if (fobj.getParent() instanceof TableHeader) {
- TableHeader parentHeader=(TableHeader)fobj.getParent();
+ TableHeader parentHeader = (TableHeader)fobj.getParent();
brd = parentHeader.getCommonBorderPaddingBackground();
color = brd.backgroundColor;
}
if (color == null
- && fobj.getParent()!=null
- && fobj.getParent().getParent()!=null
- && fobj.getParent().getParent().getParent() instanceof Table) {
-
- Table table = (Table)fobj.getParent().getParent().getParent();
- brd = table.getCommonBorderPaddingBackground();
- color = brd.backgroundColor;
+ && fobj.getParent() != null
+ && fobj.getParent().getParent() != null
+ && fobj.getParent().getParent().getParent() instanceof Table) {
+
+ Table table = (Table)fobj.getParent().getParent().getParent();
+ brd = table.getCommonBorderPaddingBackground();
+ color = brd.backgroundColor;
}
RtfAttributes rtfatts)
throws FOPException {
- Property p;
- RtfColorTable colorTable = RtfColorTable.getInstance();
+ //Property p;
+ //RtfColorTable colorTable = RtfColorTable.getInstance();
RtfAttributes attrib = null;
attrib = rtfatts;
}
- String attrValue;
- boolean isBorderPresent = false;
+ //String attrValue;
+ //boolean isBorderPresent = false;
//need to set a default width
//check for keep-together row attribute
* @throws IOException for I/O problems
*/
protected void writeRtfPrefix() throws IOException {
- if (isNestedTable()) {
- writeControlWordNS("pard");
- }
-
+ if (isNestedTable()) {
+ writeControlWordNS("pard");
+ }
+
writeGroupMark(true);
}
protected void writeRtfSuffix() throws IOException {
writeGroupMark(false);
- if(isNestedTable()) {
- getRow().writeRowAndCellsDefintions();
+ if (isNestedTable()) {
+ getRow().writeRowAndCellsDefintions();
}
}
return super.getRtfAttributes();
}
+ /** @return true if the the table is a nested table */
public boolean isNestedTable() {
- if (isNestedTable == null) {
- RtfElement e=this;
- while(e.parent != null) {
- if (e.parent instanceof RtfTableCell) {
- isNestedTable=new Boolean(true);
- return true;
- }
-
- e = e.parent;
- }
-
- isNestedTable=new Boolean(false);
- } else {
- return isNestedTable.booleanValue();
- }
-
- return false;
+ if (isNestedTable == null) {
+ RtfElement e = this;
+ while (e.parent != null) {
+ if (e.parent instanceof RtfTableCell) {
+ isNestedTable = Boolean.TRUE;
+ return true;
+ }
+
+ e = e.parent;
+ }
+
+ isNestedTable = Boolean.FALSE;
+ } else {
+ return isNestedTable.booleanValue();
+ }
+
+ return false;
}
public RtfTableRow getRow() {
- RtfElement e=this;
- while(e.parent != null) {
- if (e.parent instanceof RtfTableRow) {
- return (RtfTableRow) e.parent;
- }
-
- e = e.parent;
- }
-
- return null;
+ RtfElement e = this;
+ while (e.parent != null) {
+ if (e.parent instanceof RtfTableRow) {
+ return (RtfTableRow) e.parent;
+ }
+
+ e = e.parent;
+ }
+
+ return null;
}
}
*/
public class RtfTableCell
-extends RtfContainer
-implements IRtfParagraphContainer, IRtfListContainer, IRtfTableContainer,
- IRtfExternalGraphicContainer, IRtfTextrunContainer {
+ extends RtfContainer
+ implements IRtfParagraphContainer, IRtfListContainer, IRtfTableContainer,
+ IRtfExternalGraphicContainer, IRtfTextrunContainer {
private RtfParagraph paragraph;
private RtfList list;
private RtfTable table;
* @throws IOException for I/O problems
*/
protected void writeRtfSuffix() throws IOException {
- if (getRow().getTable().isNestedTable()) {
- //nested table
- writeControlWordNS("nestcell");
- writeGroupMark(true);
- writeControlWord("nonesttables");
- writeControlWord("par");
- writeGroupMark(false);
- } else {
- // word97 hangs if cell does not contain at least one "par" control word
- // TODO this is what causes the extra spaces in nested table of test
- // 004-spacing-in-tables.fo,
- // but if is not here we generate invalid RTF for word97
-
- if (setCenter) {
- writeControlWord("qc");
- } else if (setRight) {
- writeControlWord("qr");
- } else {
- writeControlWord("ql");
- }
-
-
-
- if (!containsText()) {
- writeControlWord("intbl");
-
- //R.Marra this create useless paragraph
- //Seem working into Word97 with the "intbl" only
- // writeControlWord("par");
- }
-
- writeControlWord("cell");
- }
+ if (getRow().getTable().isNestedTable()) {
+ //nested table
+ writeControlWordNS("nestcell");
+ writeGroupMark(true);
+ writeControlWord("nonesttables");
+ writeControlWord("par");
+ writeGroupMark(false);
+ } else {
+ // word97 hangs if cell does not contain at least one "par" control word
+ // TODO this is what causes the extra spaces in nested table of test
+ // 004-spacing-in-tables.fo,
+ // but if is not here we generate invalid RTF for word97
+
+ if (setCenter) {
+ writeControlWord("qc");
+ } else if (setRight) {
+ writeControlWord("qr");
+ } else {
+ writeControlWord("ql");
+ }
+
+ if (!containsText()) {
+ writeControlWord("intbl");
+
+ //R.Marra this create useless paragraph
+ //Seem working into Word97 with the "intbl" only
+ //writeControlWord("par");
+ }
+
+ writeControlWord("cell");
+ }
}
return result;
}
- public RtfTextrun getTextrun()
- throws IOException {
+ public RtfTextrun getTextrun() throws IOException {
RtfAttributes attrs = new RtfAttributes();
- if(!getRow().getTable().isNestedTable()) {
- attrs.set("intbl");
+ if (!getRow().getTable().isNestedTable()) {
+ attrs.set("intbl");
}
RtfTextrun textrun = RtfTextrun.getTextrun(this, writer, attrs);
}
public RtfTableRow getRow() {
- RtfElement e=this;
- while(e.parent != null) {
- if (e.parent instanceof RtfTableRow) {
- return (RtfTableRow) e.parent;
- }
-
- e = e.parent;
- }
-
- return null;
+ RtfElement e = this;
+ while (e.parent != null) {
+ if (e.parent instanceof RtfTableRow) {
+ return (RtfTableRow) e.parent;
+ }
+
+ e = e.parent;
+ }
+
+ return null;
}
}
*/
protected void writeRtfContent() throws IOException {
- if (getTable().isNestedTable()) {
- //nested table
- writeControlWord("intbl");
- writeControlWord("itap2");
- } else {
- //normal (not nested) table
- writeRowAndCellsDefintions();
- }
+ if (getTable().isNestedTable()) {
+ //nested table
+ writeControlWord("intbl");
+ writeControlWord("itap2");
+ } else {
+ //normal (not nested) table
+ writeRowAndCellsDefintions();
+ }
// now children can write themselves, we have the correct RTF prefix code
super.writeRtfContent();
}
public void writeRowAndCellsDefintions() throws IOException {
-// render the row and cells definitions
+ // render the row and cells definitions
writeControlWord("trowd");
if (!getTable().isNestedTable()) {
- writeControlWord("itap0");
+ writeControlWord("itap0");
}
-
+
//check for keep-together
if (attrib != null && attrib.isSet(ITableAttributes.ROW_KEEP_TOGETHER)) {
writeControlWord(ROW_KEEP_TOGETHER);
* @throws IOException for I/O problems
*/
protected void writeRtfSuffix() throws IOException {
- if (getTable().isNestedTable()) {
- //nested table
- writeGroupMark(true);
- writeStarControlWord("nesttableprops");
- writeRowAndCellsDefintions();
- writeControlWordNS("nestrow");
- writeGroupMark(false);
-
-
- writeGroupMark(true);
- writeControlWord("nonesttables");
- writeControlWord("par");
- writeGroupMark(false);
- } else {
- writeControlWord("row");
- }
+ if (getTable().isNestedTable()) {
+ //nested table
+ writeGroupMark(true);
+ writeStarControlWord("nesttableprops");
+ writeRowAndCellsDefintions();
+ writeControlWordNS("nestrow");
+ writeGroupMark(false);
+
+ writeGroupMark(true);
+ writeControlWord("nonesttables");
+ writeControlWord("par");
+ writeGroupMark(false);
+ } else {
+ writeControlWord("row");
+ }
writeGroupMark(false);
}
}
public RtfTable getTable() {
- RtfElement e=this;
- while(e.parent != null) {
- if (e.parent instanceof RtfTable) {
- return (RtfTable) e.parent;
- }
-
- e = e.parent;
- }
-
- return null;
+ RtfElement e = this;
+ while (e.parent != null) {
+ if (e.parent instanceof RtfTable) {
+ return (RtfTable) e.parent;
+ }
+
+ e = e.parent;
+ }
+
+ return null;
}
}