import java.util.Iterator;
import java.io.IOException;
-/*
- * RtfJforCmd process "jfor-cmd"
- *
+/**
+ * Process "jfor-cmd"
*/
public class RtfJforCmd extends RtfContainer {
- private final String PARA_KEEP_ON = "para-keep:on";
- private final String PARA_KEEP_OFF = "para-keep:off";
+ private static final String PARA_KEEP_ON = "para-keep:on";
+ private static final String PARA_KEEP_OFF = "para-keep:off";
- private final RtfAttributes m_attrib;
- private ParagraphKeeptogetherContext m_paragraphKeeptogetherContext;
+ private final RtfAttributes attrib;
+ private ParagraphKeeptogetherContext paragraphKeeptogetherContext;
RtfJforCmd(RtfContainer parent, Writer w, RtfAttributes attrs) throws IOException {
super((RtfContainer)parent, w);
- m_attrib = attrs;
- m_paragraphKeeptogetherContext = ParagraphKeeptogetherContext.getInstance();
+ attrib = attrs;
+ paragraphKeeptogetherContext = ParagraphKeeptogetherContext.getInstance();
}
-
+ /**
+ *
+ * @return true (alway)
+ */
public boolean isEmpty() {
return true;
}
-
+ /**
+ * Execute all jfor-cmd commands
+ * TODO: Consider creating one class for each jfor command.
+ */
public void process() {
-
- //Execute all jfor-cmd commands
- //TODO create one class for each jfor command ?
-
- for (Iterator it = m_attrib.nameIterator(); it.hasNext();) {
+ for (Iterator it = attrib.nameIterator(); it.hasNext();) {
final String cmd = (String)it.next();
if (cmd.equals(PARA_KEEP_ON)) {
- m_paragraphKeeptogetherContext.keepTogetherOpen();
+ paragraphKeeptogetherContext.keepTogetherOpen();
} else if (cmd.equals(PARA_KEEP_OFF)) {
- m_paragraphKeeptogetherContext.keepTogetherClose();
+ paragraphKeeptogetherContext.keepTogetherClose();
} else {
// this.getRtfFile ().getLog ().logInfo
// ("JFOR-CMD ignored, command not recognised:"+cmd);
}
-
-
}
\ No newline at end of file
import java.io.Writer;
import java.io.IOException;
-/** Model of an RTF list, which can contain RTF list items
- * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
+/**
+ * Model of an RTF list, which can contain RTF list items
+ * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch
* @author Christopher Scott, scottc@westinghouse.com
*/
-
public class RtfList extends RtfContainer {
- private RtfListItem m_item;
- private RtfListTable m_listTable;
- private final boolean m_hasTableParent;
+ private RtfListItem item;
+ private RtfListTable listTable;
+ private final boolean hasTableParent;
/** list numbering style.
* Could add more variables, for now we simply differentiate between bullets and numbering
*/
- private NumberingStyle m_numberingStyle;
+ private NumberingStyle numberingStyle;
+
+ /**
+ * Inner static class to handle numbering styles.
+ */
public static class NumberingStyle {
- public boolean isBulletedList = true;
+ private boolean isBulletedList = true;
+
+ /**
+ * accessor for isBulletedList
+ * @return isBulletedList
+ */
+ public boolean getIsBulletedList() {
+ return isBulletedList;
+ }
+
+ /**
+ * set isBulletedList
+ * @param isBL boolean value to set
+ */
+ public void setIsBulletedList(boolean isBL) {
+ isBulletedList = isBL;
+ }
}
/** Create an RTF list as a child of given container with given attributes */
RtfList(RtfContainer parent, Writer w, RtfAttributes attr) throws IOException {
super((RtfContainer)parent, w, attr);
- m_numberingStyle = new NumberingStyle();
+ numberingStyle = new NumberingStyle();
//create a new list table entry for the list
- m_listTable = (getRtfFile()).startListTable(attr);
- m_listTable.setParentList(this);
+ listTable = (getRtfFile()).startListTable(attr);
+ listTable.setParentList(this);
// find out if we are nested in a table
- m_hasTableParent = this.getParentOfClass(RtfTable.class) != null;
+ hasTableParent = this.getParentOfClass(RtfTable.class) != null;
}
- /** change numbering style */
+ /**
+ * Change numbering style
+ * @param ns NumberingSytle to set
+ */
public void setNumberingStyle(NumberingStyle ns) {
- m_numberingStyle = ns;
+ numberingStyle = ns;
}
- /** overridden to setup the list: start a group with appropriate attributes */
+ /**
+ * Overridden to setup the list: start a group with appropriate attributes
+ * @throws IOException for I/O problems
+ */
protected void writeRtfPrefix() throws IOException {
// pard causes word97 (and sometimes 2000 too) to crash if the list is nested in a table
- if (!m_hasTableParent) {
+ if (!hasTableParent) {
writeControlWord("pard");
}
//Modified by Chris Scott
//fixes second line indentation
- if (m_numberingStyle.isBulletedList) {
+ if (numberingStyle.isBulletedList) {
// bulleted list
writeControlWord("pnlvlblt");
writeControlWord("ilvl0");
writeOneAttribute(RtfListTable.LIST_NUMBER,
- (m_listTable.getListNumber()).toString());
+ (listTable.getListNumber()).toString());
writeOneAttribute("pnindent",
attrib.getValue(RtfListTable.LIST_INDENT));
writeControlWord("pnf1");
writeControlWord("pnlvlbody");
writeControlWord("ilvl0");
writeOneAttribute(RtfListTable.LIST_NUMBER,
- (m_numberingStyle.isBulletedList) ? "2" : "0");
+ (numberingStyle.isBulletedList) ? "2" : "0");
writeControlWord("pndec");
writeOneAttribute("pnstart",
attrib.getValue(RtfListTable.LIST_START_AT));
writeGroupMark(false);
writeOneAttribute(RtfListTable.LIST_NUMBER,
- (m_listTable.getListNumber()).toString());
+ (listTable.getListNumber()).toString());
}
- /** end the list group */
+ /**
+ * End the list group
+ * @throws IOException for I/O problems
+ */
protected void writeRtfSuffix() throws IOException {
// close group that encloses the whole list
writeGroupMark(false);
* but pard causes word97 (and sometimes 2000 too) to crash if the list
* is nested in a table
*/
- if (!m_hasTableParent) {
+ if (!hasTableParent) {
writeControlWord("pard");
}
}
- /** close current list item and start a new one */
+ /**
+ * Close current list item and start a new one
+ * @return new RtfListItem
+ * @throws IOException for I/O problems
+ */
public RtfListItem newListItem() throws IOException {
- if (m_item != null) {
- m_item.close();
+ if (item != null) {
+ item.close();
}
- m_item = new RtfListItem(this, writer);
- return m_item;
+ item = new RtfListItem(this, writer);
+ return item;
}
- /** true if this is a bulleted list (as opposed to numbered list) */
+ /**
+ * @return true if this is a bulleted list (as opposed to numbered list)
+ */
public boolean isBulletedList() {
- return m_numberingStyle.isBulletedList;
+ return numberingStyle.isBulletedList;
}
}
\ No newline at end of file
public class RtfListItem
extends RtfContainer
implements IRtfParagraphContainer {
- private RtfList m_parentList;
- private RtfParagraph m_paragraph;
+ private RtfList parentList;
+ private RtfParagraph paragraph;
/** special RtfParagraph that writes list item setup code before its content */
private class RtfListItemParagraph extends RtfParagraph {
protected void writeRtfPrefix() throws IOException {
super.writeRtfPrefix();
// for bulleted list, add list item setup group before paragraph contents
- if (m_parentList.isBulletedList()) {
+ if (parentList.isBulletedList()) {
writeGroupMark(true);
writeControlWord("pntext");
writeControlWord("f" + RtfFontManager.getInstance().getFontNumber("Symbol"));
/** Create an RTF list item as a child of given container with default attributes */
RtfListItem(RtfList parent, Writer w) throws IOException {
super((RtfContainer)parent, w);
- m_parentList = parent;
+ parentList = parent;
}
/** Create an RTF list item as a child of given container with given attributes */
RtfListItem(RtfList parent, Writer w, RtfAttributes attr) throws IOException {
super((RtfContainer)parent, w, attr);
- m_parentList = parent;
+ parentList = parent;
}
- /** close current paragraph and start a new one */
- /** close current paragraph if any and start a new one */
+ /**
+ * 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
+ */
public RtfParagraph newParagraph(RtfAttributes attrs) throws IOException {
- if (m_paragraph != null) {
- m_paragraph.close();
+ if (paragraph != null) {
+ paragraph.close();
}
- m_paragraph = new RtfListItemParagraph(this, attrs);
- return m_paragraph;
+ paragraph = new RtfListItemParagraph(this, attrs);
+ return paragraph;
}
- /** close current paragraph if any and start a new one with default attributes */
+ /**
+ * Close current paragraph if any and start a new one with default attributes
+ * @return new RtfParagraph
+ * @throws IOException for I/O problems
+ */
public RtfParagraph newParagraph() throws IOException {
return newParagraph(null);
}