if (bDefer) {
return;
}
-
+
// create an RtfListItem in the current RtfList
try {
- final RtfList list = (RtfList)builderContext.getContainer(
+ RtfList list = (RtfList)builderContext.getContainer(
RtfList.class, true, this);
+
+ /**
+ * If the current list already contains a list item, then close the
+ * list and open a new one, so every single list item gets its own
+ * list. This allows every item to have a different list label.
+ * If all the items would be in the same list, they had all the
+ * same label.
+ */
+ //TODO: do this only, if the labels content <> previous labels content
+ if (list.getChildCount() > 0) {
+ this.endListBody();
+ this.endList((ListBlock) li.getParent());
+ this.startList((ListBlock) li.getParent());
+ this.startListBody();
+
+ list = (RtfList)builderContext.getContainer(
+ RtfList.class, true, this);
+ }
+
builderContext.pushContainer(list.newListItem());
} catch (IOException ioe) {
log.error("startList: " + ioe.getMessage());
* the RTF file itself (for easier debugging), not its content.
* @throws IOException in case of an I/O problem
*/
- protected void newLine() throws IOException {
+ public void newLine() throws IOException {
writer.write("\n");
}
/* $Id$ */
+package org.apache.fop.render.rtf.rtflib.rtfdoc;
/*
* This file is part of the RTF library of the FOP project, which was originally
* the FOP project.
*/
-package org.apache.fop.render.rtf.rtflib.rtfdoc;
-
import java.io.Writer;
import java.io.IOException;
import java.util.Date;
private RtfListStyle defaultListStyle;
private Integer listTemplateId = null;
private Integer listId = null;
- static private Random listIdGenerator = new Random(0);
+ private static Random listIdGenerator = new Random(0);
/** Create an RTF list as a child of given container with given attributes */
RtfList(RtfContainer parent, Writer w, RtfAttributes attr) throws IOException {
return item;
}
+ /**
+ * Returns the Id of the list.
+ * @return Id of the list
+ */
public Integer getListId() {
return listId;
}
+ /**
+ * Returns the Id of the list template.
+ * @return Id of the list template
+ */
public Integer getListTemplateId() {
return listTemplateId;
}
return defaultListStyle;
}
+ /**
+ * Returns true, if the list has a parent table.
+ * @return true, if the list has a parent table
+ */
public boolean getHasTableParent() {
return hasTableParent;
}
/* $Id$ */
+package org.apache.fop.render.rtf.rtflib.rtfdoc;
/*
* This file is part of the RTF library of the FOP project, which was originally
* the FOP project.
*/
-package org.apache.fop.render.rtf.rtflib.rtfdoc;
-
import java.io.Writer;
import java.io.IOException;
private RtfListStyle listStyle;
private int number = 0;
- /** special RtfParagraph that writes list item setup code before its content */
+ /**
+ * special RtfParagraph that writes list item setup code before its content
+ */
private class RtfListItemParagraph extends RtfParagraph {
RtfListItemParagraph(RtfListItem rli, RtfAttributes attrs)
}
}
+ /**
+ * special RtfTextrun that is used as list item label
+ */
public class RtfListItemLabel extends RtfTextrun implements IRtfTextrunContainer {
private RtfListItem rtfListItem;
+ /**
+ * Constructs the RtfListItemLabel
+ * @param item The RtfListItem the label belongs to
+ * @throws IOException Thrown when an IO-problem occurs
+ */
public RtfListItemLabel(RtfListItem item) throws IOException {
super(null, item.writer, null);
rtfListItem = item;
}
+ /**
+ * Returns the current RtfTextrun object.
+ * Opens a new one if necessary.
+ * @return The RtfTextrun object
+ * @throws IOException Thrown when an IO-problem occurs
+ */
public RtfTextrun getTextrun() throws IOException {
return this;
}
+ /**
+ * Sets the content of the list item label.
+ * @param s Content of the list item label.
+ * @throws IOException Thrown when an IO-problem occurs
+ */
public void addString(String s) throws IOException {
final String label = s.trim();
* Close current paragraph if any and start a new one
* @param attrs attributes of new paragraph
* @return new RtfParagraph
- * @throws IOException for I/O problems
+ * @throws IOException Thrown when an IO-problem occurs
*/
public RtfParagraph newParagraph(RtfAttributes attrs) throws IOException {
if (paragraph != null) {
/**
* Close current paragraph if any and start a new one with default attributes
* @return new RtfParagraph
- * @throws IOException for I/O problems
+ * @throws IOException Thrown when an IO-problem occurs
*/
public RtfParagraph newParagraph() throws IOException {
return newParagraph(null);
parentList = parent;
}
+
+ /**
+ * Get the current textrun.
+ * @return current RtfTextrun object
+ * @throws IOException Thrown when an IO-problem occurs
+ */
public RtfTextrun getTextrun() throws IOException {
RtfTextrun textrun = RtfTextrun.getTextrun(this, writer, null);
textrun.setRtfListItem(this);
writeControlWord("pard");
}
- writeOneAttribute(RtfText.LEFT_INDENT_FIRST, "360"); //attrib.getValue(RtfListTable.LIST_INDENT));
- writeOneAttribute(RtfText.LEFT_INDENT_BODY, attrib.getValue(RtfText.LEFT_INDENT_BODY));
+ writeOneAttribute(RtfText.LEFT_INDENT_FIRST,
+ "360"); //attrib.getValue(RtfListTable.LIST_INDENT));
+
+ writeOneAttribute(RtfText.LEFT_INDENT_BODY,
+ attrib.getValue(RtfText.LEFT_INDENT_BODY));
// group for list setup info
writeGroupMark(true);
return parentList;
}
+ /**
+ * Returns the list number
+ * @return list number
+ */
public int getNumber() {
return number;
}
/* $Id$ */
+package org.apache.fop.render.rtf.rtflib.rtfdoc;
/*
* This file is part of the RTF library of the FOP project, which was originally
* the FOP project.
*/
-package org.apache.fop.render.rtf.rtflib.rtfdoc;
-
import java.util.LinkedList;
import java.util.Iterator;
import java.io.Writer;
/**
* Add List
* @param list RtfList to add
+ * @return number of lists in the table after adding
*/
public int addList(RtfList list) {
if (lists == null) {
* @throws IOException for I/O problems
*/
public void writeRtfContent() throws IOException {
+ newLine();
if (lists != null) {
//write '\listtable'
- writeGroupMark(true);
- writeStarControlWordNS(LIST_TABLE);
+ writeGroupMark(true);
+ writeStarControlWordNS(LIST_TABLE);
+ newLine();
for (Iterator it = lists.iterator(); it.hasNext();) {
final RtfList list = (RtfList)it.next();
writeListTableEntry(list);
+ newLine();
}
writeGroupMark(false);
-
+
+ newLine();
//write '\listoveridetable'
- writeGroupMark(true);
+ writeGroupMark(true);
writeStarControlWordNS(LIST_OVR_TABLE);
int z = 1;
-
+ newLine();
for (Iterator it = styles.iterator(); it.hasNext();) {
final RtfListStyle style = (RtfListStyle)it.next();
writeGroupMark(false);
writeGroupMark(false);
+ newLine();
}
writeGroupMark(false);
+ newLine();
}
}
}
/**
- * Change list style
+ * Add list style
* @param ls ListStyle to set
+ * @return number of styles after adding
*/
public int addRtfListStyle(RtfListStyle ls) {
styles.add(ls);
*/
protected void writeRtfPrefix() throws IOException {
writeAttributes(attrib, RtfPage.PAGE_ATTR);
+ newLine();
writeControlWord("sectd");
}